Farseer.net Lightweight ORM Open source framework v1.x: Stored Procedure Data operations

Source: Internet
Author: User

Navigation

Catalog: Farseer.net Lightweight ORM Open source Framework Catalog

Previous: Farseer.net Lightweight ORM Open source framework v1.x : Stored procedure entity class mappings

Filed under: Farseer.net Lightweight ORM Open source framework v1.x : Table/View Cache operations Tablecahceset, Viewcahceset

Objective

In the previous article, we learned about the relational mapping of stored procedures, which know that the stored procedure needs to be used: Procset as the context of the operation, and on the field attribute, we know that the new two properties are used to store the parameter input and output of the procedure.

At the end of the previous article, 4 attribute methods were mentioned. This is a simple tutorial.

For Insertuservo, the client invocation example:
    var New " now111 " " old222 "  };    Proc. Data. Insertuser. Execute (info);

  Insertuser is a property of the procset<insertuservo> type, which in the previous article can be seen as defined.

From the entities we define, we can see: UserName, password are Isinparam = True , that is, they are the parameters (stored procedures) we want to pass in Insertuservo. The ID is an out parameter .

So after executing execute, the SQL parameters are generated and executed into the "sp_insert_user" stored procedure by username, password. The ID of the Out parameter is also set, and the out parameter is returned and assigned to the ID attribute .

Methods provided by Procset
        /// <summary>        ///returns the value of the query/// </summary>        /// <param name= "entity" >passing in an entity that is set to assign a value to a parameter</param>        /// <param name= "T" >value returned on Failure</param>         PublicT getvalue<t> (TEntity entity =NULL, T t =default(T))/// <summary>        ///Executing stored procedures/// </summary>        /// <param name= "entity" >passing in an entity that is set to assign a value to a parameter</param>         Public voidExecute (TEntity entity =NULL)        /// <summary>        ///return a single record/// </summary>        /// <param name= "entity" >passing in an entity that is set to assign a value to a parameter</param>         PublicTEntity toentity (TEntity entity =NULL)        /// <summary>        ///return multiple records/// </summary>        /// <param name= "entity" >passing in an entity that is set to assign a value to a parameter</param>         PublicList<tentity> ToList (TEntity entity =NULL)

According to what we often encounter, there are 4 types of stored procedure executions that are specifically provided:

    1. Returns the value of a query (single value)
    2. Execute stored procedure (no return value, out will still return and assign value)
    3. Return a single record
    4. return multiple records

The operation of the stored procedure is very simple. Just before the 4 methods provided above, the entities passing in the required parameter types can execute the stored procedure we want, thus implementing the stored procedure mapping we are talking about.

Bloggers do not call each of these 4 methods to explain.

As for which method to execute, you need to choose the type that you want to return after execution, depending on the definition of your stored procedure.

  

No return after the stored procedure executes (out parameter not counted), call: Execute

If you return a list, single-valued (single-field), or individual records, you can find the corresponding execution method.

Summarize

In fact, at least, the majority of the operation of Farseer.net we have finished. By learning here, you can already use it in a real project.

The next tutorial is nothing more than a feature that you might not be able to use. So start now, download it and apply it to your project (for the purpose of learning)

Farseer.net to do well, need everyone's efforts, need your planning, once accepted, Bo will be implemented in the next version.

In fact, many of the functions are now put forward by everyone. Published in the sweat of the Bo Lord. From which we can learn different angles of knowledge.

What are you waiting for? Quickly join us: QQ Group:116228666 (farseer.net Open source frame exchange) Please specify:farseer.net

Navigation

Catalog: Farseer.net Lightweight ORM Open source Framework Catalog

Previous: Farseer.net Lightweight ORM Open source framework v1.x : Stored procedure entity class mappings

Filed under: Farseer.net Lightweight ORM Open source framework v1.x : Table/View Cache operations Tablecahceset, Viewcahceset

Advertising time

QQ Group:116228666 (farseer.net Open source frame exchange) Please specify:farseer.net

Farseer.net is an ORM framework + Common tool + extension collection.

Farseer implication: Prophets and seers usually offer tricks and strategies in certain situations. Also hope that the framework can provide you with maximum convenience.

ORM: The English name is:object relational(relationship) Mapping(map)

Farseer.net's goal is: Quick start, rapid development, simple and convenient.

1Table.data.User. Where (O=>o.id = =1). toentity ();2Table.data.User. Where (O=>o.id >1). ToList ();3Table.data.User. Where (o=>o.id! =0). Delete ();4Table.data.User. Where (o=>o.id! =0).Addup(O=>o.logincount,1);5Table.data.User. Where (O=>o.id = =1).Update(Newuser{UserName ="NewName" });6Table.data.User.Insert(Newuser{UserName ="NewName"});

Farseer.net Lightweight ORM Open source framework v1.x: Stored Procedure Data operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.