CYQ.Data 数据层框架

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

CYQ.Data Components Getting Started Guide [Part 2]-[MAction Data Query- Fill And Select]

快速使用帮助 | | | 发表日期 :2011/7/2 17:11:28#楼主  

In this section: [with * content for the new version of the performance function, the old version might not have this feature]

Benpian continue on a content, this section describes the use of all relevant queries.
 
 Main Summary:
 
 1: Fill one-line data manipulation operations and GetCount, Exists (*) operation.
 
 2: Select multiple lines of data manipulation operations
 
 3: list-bound controls operate with the paging controls
 
 4: multi-table query and bind the view and custom SQL
 

Single data operation

I:Fill - a single query

Method Prototype:public bool Fill(object where)

Example 1: Direct ID

using(MAction action = new MAction(TableNames.Users))
{
        if (action.Fill(888))//Query ID = 888 one-way data

        {
                action.SetTo(lblUserName);
        }
}

Example 2: where conditions for transmission

using(MAction action = new MAction(TableNames.Users))
{
        if (action.Fill("id=888 or UserName='cyqdata"))//Query  ID=888 or UserName is "cyqdata" one-way data
        {
                action.SetTo(lblUserName);
        }
}

Example 3: where conditions are attached order by

using(MAction action = new MAction(TableNames.Users))
{
        if (action.Fill("id>888 order by id desc"
))//Query  ID>888' result,ID to take the results of the largest single data
        {
                action.SetTo(lblUserName);
        }
}

Example 4: MDataRow line data transfer entity

using(MAction action = new MAction(TableNames.Users))
{
        if (action.Fill("888"))

        {
                 UserInfo info=action.Data.ToEntity<UserInfo>();//UserInfo transfer entity。 

        }
}

II:GetCount -Take the total number of statistics

Method Prototype:public int GetCount(string where)

Example

using(MAction action = new MAction(TableNames.Users))
{
        int count=action.GetCount("id>10"
);
}

III:Exists - The existence of the conditions specified data (*)

Method Prototype:public int Exists(string where)

Example

using(MAction action = new MAction(TableNames.Users))
{
        bool userExists=action.Exists("UserName='cyqdata'"
);
}

 

Multi-line data manipulation

Ⅳ:Select - Multiple Data Query

Method Prototype:
1public
MDataTable Select()
2public MDataTable Select(string where)(*)
3public MDataTable Select(int PageIndex, int PageSize, string Where, out int
RowCount)

Example 1:

using(MAction action = new MAction(TableNames.Users))
{
       MDataTable tabme
= action.Select();//Select All Data

}

Example 2:

using(MAction action = new MAction(TableNames.Users))
{
       MDataTable tabme
= action.Select("id>10 order by id desc");//Select data by where

}

Example 3:

int count;// return record count
using(MAction action = new MAction(TableNames.Users))
{
       MDataTable tabme
= action.Select(1,10,"id>10 order by id desc",out count);
       //Select Data by where and with pager
}

 

List of bind operation

Ⅴ:Bind To GridView/DataList/Repeater

Example 1: Select All And Bind To List Control

using(MAction action = new MAction(TableNames.Users))
{
       
action.Select().Bind(gvUsers);
}

Example 2:Bind with paging controls

[Down Paging Control:http://www.cyqdata.com/download/article-detail-28683]

public void BindData()
{
        int
count;
        using(MAction action = new MAction(TableNames.Users))
        {
               
action.Select(Pager1.PageIndexPager1.PageSize"id>10 order by id desc",out count).Bind(gvUsers);
        }
         Pager1.Count = count;//Set Record Count
         Pager1.BindName = "BindData";//Bind Method Name,Symbols need to modify Public
}

 

Multi-table query and bind

Ⅵ:View Way

Example 1:And operation of the same table, the only difference is the name of the table name into view

using(MAction action = new MAction(ViewNames.V_Users))
{
       MDataTable tabme
= action.Select();//Select All View Data

}

 

Ⅶ:Multi-table query: Customize multi-table SQL statement construct

Example 1:

public void BindData()
{
        string customTable = "(select u.*,m.Body from Users u left join Message m on u.ID=m.UserID) v";

        int
count;
        using(MAction action = new MAction(customTable))
        {
               
action.Select(Pager1.PageIndexPager1.PageSize"id>10 order by id desc",out count).Bind(gvUsers);
        }
         Pager1.Count = count;
         Pager1.BindName = "BindData";
}

Description:

In the specific use, in order to facilitate the management, directly in a custom SQL statement is not written directly in the interface so, you can build a new item unified project management custom SQL.

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

More tutorials:



新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"
Anderson[176.31.68.*]2012/6/6 11:01:34#1
altazar / Проверил сейчас. Прежний HUD возвращается, если удалить файлы мода.Steam/steamapps/common/skyrim/Data/Interface. Оттуда удали папку exported и файл faemtirvsoenu

发表评论

论坛公告

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


    在线帮助:欢迎联系

帖子搜索