Lightweight road data CYQ.Data layers using four articles MAction CRUD (XV)

Previous: CYQ.Data lightweight way to use the data layer of chapter three MAction value assignment (xiv)

 

In this part Summary

Benpian continue on a content-related operations This section describes all of the additions and deletions.
1 : Insert method to add data
2
: Delete Data Delete method
3
: Update method to update the data
On the blog address: http://cyq1162.cnblogs.com/

 

 

A: add operation

Method Prototype:
public BOOL  the Insert () public BOOL  the Insert ( BOOL  AutoSetValue)  
 

 

Example 1:

Action MAction  = new new  MAction (TableNames.Users); action.Set (Users.UserName,  " passing the fall " ); // or from control values action.GetFrom (txtUserName); action.Insert (); action.Close () ;  


 

Example 2:

Action MAction  = new new  MAction (TableNames.Users); action.SetAutoPrefix ( " TXT " ); // set control prefix may be provided a plurality of action.Insert ( to true ); action.Close ();  


 

Another: SetAutoPrefix automatic setting method prefix

方法原形: public   void  SetAutoPrefix( string  autoPrefix,  params   string [] otherPrefix)

 

A plurality of prefixes may be provided as an example:

action.SetAutoPrefix( " txt " , " ddl " , " lab " );

 

 

 

Two: delete

Method Prototype:
public BOOL  the Delete () public BOOL  the Delete ( Object WHERE )  
   

 

Example 1:

MAction action  =   new  MAction(TableNames.Users);
action.Set(Users.ID, 
1 );
action.Delete();
action.Close();

 

Example 2:

MAction action  =   new  MAction(TableNames.Users);
action.Delete(
" id=1 or UserName='路过秋天' " );
action.Close();

Example 3:

MAction action  =   new  MAction(TableNames.Users);
if  (action.Fill( 1 ))
{
    
// 处理其它事情
    if  (action.Delete())
   {
       action.Close();
   }
}

 

 

III: update

方法原型:
public   bool  Update()
public   bool  Update( object   where )
public   bool  Update( object   where bool  AutoSetValue)

Example 1:

MAction action  =   new  MAction(TableNames.Users);
action.Set(Users.ID, 
1 );
action.Set(Users.Password, 
" http://cyq1162.cnblogs.com " );
action.Update();
// 更新UserID为1的密码
action.Close();

 

Example 2:

MAction action  =   new  MAction(TableNames.Users);
action.Set(Users.Password, 
" http://cyq1162.cnblogs.com " );
action.Update(
" UserName='路过秋天' " );
action.Close();

 

Example 3:

05233153_J0U3.gif
Action MAction  = new new  MAction (TableNames.Users); action.SetAutoPrefix ( " TXT " ); action.Set (Users.Password,  " http://cyq1162.cnblogs.com " ); action.GetFrom (txtUserName); Action. the Update ( " ID =. 1 " , to true ); action.Close (); // description, in addition to explicitly set the password and user name taken from a control, did not show the other values of other attributes of the users table, from txt the value for the prefix control. // other properties similar to automatically obtain the value of: taking Request value [ "txtFullName"] assigns FullName property.  






 

Knot words:

This section explains by, you should be able to grasp the basic CRUD operations for data.
If you have an unknown in use, to please leave a message.

 

Attachment: either do not open, since open source, you have to strive to write relevant articles, so readers interested in this framework to help, as not interested, skip to Wu Wu. 

Reproduced in: https: //my.oschina.net/secyaher/blog/274058

Guess you like

Origin blog.csdn.net/weixin_33909059/article/details/91966769