Model of Sod frame, connection database and deletion and modification

Source: Internet
Author: User
Tags connectionstrings

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

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.