CYQ.Data 数据层框架

CYQ.Data 是一款由路过秋天创作的支持多数据库应用[Txt,Xml,Access,MSSQL,Oracle,SQLite,MySql]的底层数据库操作类库,使用本类库可以轻松快速开发项目(QQ群:6033006)。

CYQ.Data Components Getting Started Guide [Part 4]-[MAction Insert Delete Update]

快速使用帮助 | | | 发表日期 :2011/7/2 18:31:20#楼主  

In this section:

continue on a content, all of this section to Insert , delete, Update , related operations.
 
 1: Insert method to add data

 2: Delete method to delete data

 3: Update method to update data

一:Insert Operation

Method Prototype:
 
public bool Insert()

public bool Insert(bool
autoSetValue)
 
public bool Insert(bool autoSetValue, InsertOption option)

Example 1:

using(MAction action = new MAction(TableNames.Users))
{
        action.Set(Users.NickName,
"cyqdata");//Non-UI Set Value
        action.GetFrom(txtUserName)//UI Set Value
        if(action.Insert())
        {
                 int id=action.Get<int>(Users.ID);//Back into the post-primary key ID
        }
}

Example 2:

using(MAction action = new MAction(TableNames.Users))
{
        action.Set(Users.NickName, "cyqdata");
        action.GetFrom(txtUserName)
        action.SetAutoPrefix("txt"); //Control prefix setting, you can set more than one

        action.Insert(true);//In addition to the assigned set, the other table fields automatically from Request ["txt field"] in value.
}

Another: SetAutoPrefix automatic prefix method

Method Prototype : public void SetAutoPrefix(string autoPrefix, params string[] otherPrefix)

More than one prefix can be set as an example:

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

Example 3:

using(MAction action = new MAction(TableNames.Users))
{
        action.Set(Users.NickName, "cyqdata");
        action.GetFrom(txtUserName)
        action.Insert(false,InsertOption.ID);//After insertion, have only been increased from ID
}

InsertOption Enumeration Description:

/// <summary>
    /// Option to insert the return value of the data
    /// </summary>
    public enum InsertOption
    {
        /// <summary>
        /// Use this: insert data [MSSQL will return ID, other databases will not return ID]
        /// </summary>
        None,
        /// <summary>
        /// Use this: Insert data returned ID.
        /// </summary>
        ID,
        /// <summary>
        /// Use this: insert data, based on the query to return ID after filling the data line. [Default]
        /// </summary>
        Fill,
    }

二:Delete Operation

Method Prototype :

public bool
Delete()

public bool Delete(object where
)

Example 1:

using(MAction action = new MAction(TableNames.Users))
{
        action.Set(Users.ID,
1
);
        action.Delete();
}

Example 2:

using(MAction action = new MAction(TableNames.Users))
{
        action.Delete(
"id=1 or UserName='cyqdata"
);
}

三:Update Operation

Method Prototype :

public bool
Update()

public bool Update(object where
)

public bool Update(object where, bool
AutoSetValue)

Example 1:

using(MAction action = new MAction(TableNames.Users))
{
       action.Set(Users.Password, http://www.cyqdata.com
);
       action.Update(1);
//Update ID is1's password

}

Example 2:

using(MAction action = new MAction(TableNames.Users))
{
       action.Set(Users.Password, http://www.cyqdata.com
);
       action.Update(
"UserName='cyqdata"
);
}

Example 3:

using(MAction action = new MAction(TableNames.Users))
{
        action.Set(Users.NickName, "cyqdata");
        action.GetFrom(txtUserName);
        action.SetAutoPrefix("txt");
        action.Update("id=1",true);
}

Chinese version of the link:http://www.cyqdata.com/cyqdata/article-detail-414

More tutorials:



新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"
love anal[37.233.27.*]2017/3/5 6:23:35#8
GuLerm What degree could I get involving music AND creative writing?
Learn More[37.233.27.*]2017/2/1 23:10:43#7
aK26av Spot on with this write-up, I really suppose this website needs much more consideration. I?ll most likely be again to read much more, thanks for that info.
fiverr crorkservice[37.233.27.*]2015/11/9 19:46:22#6
FlNlki Very nice post. I just stumbled upon your blog and wished to say that I have really enjoyed browsing your blog posts. In any case I will be subscribing to your feed and I hope you write again soon!
crorkz matz[37.233.27.*]2014/8/6 8:16:15#5
sGENtC Hey, thanks for the blog.Really thank you! Will read on...
crorkz matz[37.233.27.*]2014/8/6 5:26:23#4
mlh330 Really enjoyed this article.Much thanks again. Great.
cheap backlinks[37.233.27.*]2014/7/19 6:46:55#3
PYcAzl Im obliged for the blog article. Keep writing.
the best seo service[192.162.19.*]2013/9/8 16:16:11#2
lSb5nn Im grateful for the article post.Thanks Again. Fantastic.
seo service[192.162.19.*]2013/9/6 6:46:07#1
c1DKfM I appreciate you sharing this blog article.Much thanks again.

发表评论

论坛公告

    数据框架 CYQ.Data QQ群:6033006
    使用本框架进行开发,入门简单,开发效率高,性能优越,更有详尽的API文档,有相关的使用帮助文章、示例文章、更甚有相关的视频教程及辅助工具。 关键还是免费与开源,实在是居家旅行、项目开发、学习研究的必备良品!!!!!!


    在线帮助:欢迎联系

帖子搜索