![]() | CYQ.Data componentsCYQ.Data support multi-database application [Txt,Xml,Access, MSSQL, Oracle,SQLite,MySql], help easily and quickly to develop your project |
CYQ.Data 数据框架 版本发布 V1.0
Platform for dynamic |
|
|
| #TopicOwner |
今天,花了N小时重构了以前的代码,删除了没用到的重截,优化代码,调整结构,重新上路,坚持把路走完!!! 1. CyQ.Data 介绍 DLL下载:点击下载 [大小:56K 没加密没混淆没限制,可放心使用,可直接用Reflector.exe查看源码,后面有开源文章续上] 类库名称空间介绍,上图: 大体情况说明: ![]() ![]() 1:Table文件夹下:自定义实现绑定MDataTable,远离DataTable 2:Cache文件夹下:用于并缓存表结构信息 3:Action文件夹下:主要操作对象 4:SQL文件夹下: DataType:提供C#数据类型和数据库类型的转换等相关信息 SQLHelper:本人精简数据库操作类: Log:用于记录数据操作异常信息 ProcedureSql:,内置查询数据表结构查询语句 OutPutData:内置sql 2000和sql 2005分页存储过程;同时提供帮助类自动生成表或视图枚举
再附说明: 本DLL原则上采取Row[索引]形式进行访问的,为了方便敲点代码,提供用枚举传参方法,内部会自动将枚举转成int,进行索引访问! 对于本系列,请读者尽量不与生成[实体类+反射组合查询语句]的型框架做相关的比较讨论!
功能特点如下: l 支持SQL Server 2000/2005/2008 .Net 2.0。其它数据库,不支持 l 只需要配置数据库链接,例如: <connectionStrings> <add name="Conn" connectionString="Server=.;database=CQSpace;uid=sa;pwd=123456"/> </connectionStrings> l 简单易用,简单使用见于下面介绍。
ps:由于本次调整代码量多,所以不知会不会改出什么问题,目前本机测试暂没发现问题,如发现bug请下面留言。
2. CyQ.Data 使用说明
该工具基于.NET 2.0,所以不能用在.NET 1.1的工程。 首先给你的工程添加Cyq.Data引用即可! 项目开始之前,请调用Cyq.Data.SQL.OutPutData下的静态方法,生成相应数据的分页存储过程如: ![]() ![]() //生成sql2005带分页的存储过程 Response.Write(CYQ.Data.SQL.OutPutData.GetSelectBaseOutPutToHtmlForSql2005()); //生成sql2000带分页的存储过程 Response.Write(CYQ.Data.SQL.OutPutData.GetSelectBaseOutPutToHtmlForSql2000()); 接着使用OutPutData生成数据库表或视图枚举: ![]() ![]() //生成枚举之后,Copy到一个类文件即可,[需要实体化,因为需要关联数据库,构造函数不传参,默认取Conn里的链接] CYQ.Data.SQL.OutPutData write = new CYQ.Data.SQL.OutPutData(); //输出表枚举 Response.Write(write.OutPutAllTableEnum(CYQ.Data.SQL.OutPutData.TableType.U, CYQ.Data.SQL.OutPutData.FiledDescriptionType.NoDescription)); //输出视图枚举 Response.Write(write.OutPutAllTableEnum(CYQ.Data.SQL.OutPutData.TableType.V, CYQ.Data.SQL.OutPutData.FiledDescriptionType.NoDescription)); 当然里面也有提供对单表的生成方法了。 接着开始项目实战了,下面示例已经过测试: 1:单行数据填充: MAction action = new MAction(TableNames.CQ_Album); if (action.Fill(1)) { lbText.Text = action.Data[CQ_Album.AlbumName].Value.ToString(); action.Close(); }
2:数据更新: MAction action = new MAction(TableNames.CQ_Album); if (action.Fill(1)) { action.Data[CQ_Album.AlbumName].Value = txtAlbumName.Text; action.Update(); action.Close(); }
数据更新方法二: MAction action = new MAction(TableNames.CQ_Album); action.Data[CQ_Album.AlbumName].Value = txtAlbumName.Text; action.Update("id=1"); action.Close();
3:数据删除: MAction action = new MAction(TableNames.CQ_Album); action.Delete(2); action.Close();
数据删除方法二: MAction action = new MAction(TableNames.CQ_Album); action.DeleteByWhere("id=2"); action.Close();
4:数据查询与绑定: 查询所有: MAction action = new MAction(TableNames.CQ_Album); gvTable.DataSource = action.Select(); gvTable.DataBind(); action.Close();
分页查询: MAction action = new MAction(TableNames.CQ_Album); int rowCount; gvTable.DataSource = action.Select(1, 10, "id>10", out rowCount); gvTable.DataBind(); action.Close();
5:多表怎么搞定? A:视图方式,将多表查询放到数据库里成视图,情况和单表一样使用; B:自定义查询语句如: ![]() ![]() string table = "(select A.*,B.Name from CQ_Album A left join CQ_UserInfo U on A.UserID=U.UserID) v"; MAction action = new MAction(table); int rowCount; gvTable.DataSource = action.Select(1, 10, "id>1", out rowCount); gvTable.DataBind(); action.Close(); 当然了,你只要把自定义的sql语句,全放一边去统一管理就行了,界面上就不要出现sql语句了!
附加: 本人从新的实体框架上引入SetTo与GetFrom方法,下一篇改造版本将从索引赋/取值中解放,敬请关注:
![]() ![]() //原索引设置值: action.Data[CQ_Album.AlbumName].Value = txtAlbumName.Text; //改进后成: action.GetFrom(txtAlbumName); //原索引读值: txtAlbumName.Text=action.Data[CQ_Album.AlbumName].Value //改进后成: action.SetTo(txtAlbumName);
OK,本开篇就点到为止,欢迎读者留言! ![]() |
Post Comment
Bulletin
Article Search
Categories
- Platform for dynamic (20)
- Feedback (9)
- Guide (33)
- Principles (19)
- Project-Case (8)
- Business & Buy (2)
- Technology exchange (45)
New Article
- CYQ.Data Components Getting Started Guide [Part 5]-[MProc Execute Stored Procedures or SQL]
- CYQ.Data Components Getting Started Guide [Part 4]-[MAction Insert Delete Update]
- CYQ.Data Components Getting Started Guide [Part 3]-[MAction Get And Set Value]
- CYQ.Data Components Getting Started Guide [Part 2]-[MAction Data Query- Fill And Select]
- CYQ.Data Components Getting Started Guide [Part 1]
New Comment
- When some one searches for his necessary thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here.
- This is my first time pay a quick visit at here and i am in fact happy to read everthing at alone place.
- I truly appreciate this blog article.Really thank you! Cool.
- please pay a visit to the web sites we follow, like this one particular, as it represents our picks in the web
- Really enjoyed this post.Really thank you!
- Really enjoyed this article.Really looking forward to read more. Great.
- poker bonuses What are the norms of copyright of web content? How as it different from Patent?
- Wow! Thank you! I permanently needed to write on my blog something like that. Can I implement a fragment of your post to my site?
- This website was how do I say it? Relevant!! Finally I ave found something that helped me. Cheers!
- I was reading through some of your content on this internet site and I believe this web site is very informative ! Continue posting.