usingPwmis. datamap.entity;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingPwmis.common;namespacegoover.models{[Serializable ()] Public Partial classStu:entitybase { PublicStu () {TableName="Stu"; Schema=""; Entitymap=entitymaptype.table; //identityname = "identity field name";Identityname ="Id"; //Primarykeys.add ("Primary key field name");Primarykeys.add ("Id"); } protected Override voidSetfieldnames () {propertynames=New string[] {"Id","Name","Sex","Createtime","Isdelete" }; } protected Override string[] setfielddescriptions () {//Description of the field return New string[] {"PRIMARY Key","Name","Gender","Creation Time","Remove Flag" }; } PublicSystem.Int32 Id {Get{returnGetproperty<system.int32> ("Id"); } Set{SetProperty ("Id", value); } } PublicSystem.String Name {Get{returnGetproperty<system.string> ("Name"); } Set{SetProperty ("Name", value); } } PublicSystem.Boolean Sex {Get{returnGetproperty<system.boolean> ("Sex"); } Set{SetProperty ("Sex", value); } } PublicSystem.DateTime Createtime {Get{returnGetproperty<system.datetime> ("Createtime"); } Set{SetProperty ("Createtime", value); } } PublicSystem.Boolean Isdelete {Get{returnGetproperty<system.boolean> ("Isdelete"); } Set{SetProperty ("Isdelete", value); } } }}
Pdf.net SOD Connection database only supports plaintext written in config file:
<configuration> <connectionStrings> <add name="studentdb" connectionstring="Data source=.;i Nitial catalog=studentdb;integrated Security=false; User Id=sa; Password=123;max Pool size=1" providername="System.Data.SqlClient" / > </connectionStrings></configuration>
You can study this: 51927469
// query: usertab user = new usertab () {UserID = 1 };OQL q =oql. From (User). select (). Where (User.userid). END; Usertab dbUser = Entityquery<usertab> // query 2: list<stu> lstu = new list<stu> (); var stulist = OQL. Fromobject<stu> (). Select (). Where ((x, c) = X.comparer (C.isdelete, " = , false )). END. ToList ();
// Delete: equivalent: delete from [Usertab] where [UserID] = 2 New = OQL. From (user). Delete (). Where (cmp = Cmp.comparer (USER.USERID,OQLCOMPARE.COMUSERTAB>. INSTANCE.EXECUTEOQL (DELETEQ);
//To update an entire entity:Usertab user =NewUsertab () {UserID =1, UserName ="Zhang San", pwd="XXX"};//update a field: equivalent: Update [usertab] set [UserName] = "John Doe", [pwd] = "XXX" where [UserID] = 1Usertab user =NewUsertab () {UserID =1, username="John Doe", pwd="XXX"};OQL Updateq=OQL. From (user). Update (user. UserName). END; Entityquery<usertab>. INSTANCE.EXECUTEOQL (UPDATEQ);//Update name only
//Insert all data:Usertab user =NewUsertab () {UserName ="Zhang San", pwd="XXX"}; Entityquery<UserTab>. Instance.insert (user);//Insert part of the data:Usertab user =NewUsertab () {UserName ="Zhang San", pwd="XXX"};OQL INSERTQ=OQL. From (user). Insert (user. UserName). END; Entityquery<usertab>. INSTANCE.EXECUTEOQL (INSERTQ);
Model of Sod frame, connection database and deletion and modification