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