Farseer.net Lightweight Open source framework getting started: adding a data story

Source: Internet
Author: User
Tags bulk insert

Navigation

Catalog: Farseer.net Lightweight Open source Framework Catalog

Previous: Farseer.net lightweight Open Source Framework introductory article: classification Logic Layer

Next: Farseer.net Lightweight open source framework Getting started: modifying data in detail

Most of the above is the principle and explanation, we will be more boring in understanding, the next few, tend to combat, will be more interesting.

Here, you can also take the users entity class to explain several ways to add in our framework.

Several ways to insert
1         New Users (); 2         " Zhang San " ; 3         Users.Data.Insert (info);
1         New " Zhang San " }. Insert ();

There are two ways to add operations to the data.

The second way is actually the process of executing the first. It's just an extension method.

Overloaded versions of Insert
1         /// <summary>2         ///Inserting Data3         /// </summary>4         /// <param name= "info" >an assigned entity</param>5         /// <param name= "db" >db for incoming transactions</param>6          Public BOOLInsert (tinfo info, Dbexecutor db =NULL);7 8         /// <summary>9         ///Inserting DataTen         /// </summary> One         /// <param name= "info" >an assigned entity</param> A         /// <param name= "db" >db for incoming transactions</param> -         /// <param name= "Identity" >identity, ID that was just inserted</param> -          Public BOOLInsert (tinfo info, out intIdentity, Dbexecutor db =NULL);

The first method is essentially the one shown above. and a second method. One more parameter: Out int identity

The self-increment ID is returned to this parameter when the database is inserted.

It is important to note that the first type also returns the self-increment. Just this value is placed on the info. The ID.

SQL Server features bulk add operations
 1  //  2  var  lst = new  list<users> ();  3  lst. ADD (new   Users ());  4  lst. ADD (new   Users ());  5  lst. ADD (new   Users ());  6  lst. ADD (new   Users ());  7  Users.Data.SqlBulkCopy (LST); 
Framework conventions

When the property is not assigned a value, that is, when the property is null. is not generated for the corresponding field SQL.

Such as:

1 New " Zhang San " }. Insert ();

The users entity actually has many fields, such as password, Gendertype, Logincount, and so on.

Because we do not assign a value to it, it is null, so. The database is not assigned a value. That is, the equivalent SQL is:

1 Insert  into Members_user (UserName)Values("Zhang San")

Navigation

Catalog: Farseer.net Lightweight Open source Framework Catalog

Previous: Farseer.net lightweight Open Source Framework introductory article: classification Logic Layer

Next: Farseer.net Lightweight open source framework Getting started: modifying data in detail

Farseer.net Lightweight Open source framework getting started: adding a data story

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.