![]() | 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.2
Platform for dynamic |
|
|
| #TopicOwner |
在上一篇:CYQ.Data 数据框架 版本发布 V1.1 之时,我通过新增加GetFrom与SetTo方法,来避免直接使用索引的取值和赋值的不便。 本来,今天是打算写个实例教程,来简单介绍用这个超轻量框架进行开发是有多轻松的事情,不过在使用时,还是发现了个别的小bug。 于是,今天狂热的修改了N多代码,抽取Sql组成部分到单独的类中,继续去掉N多重载方法,留下最简洁最实用的方法。 以面看看有哪些改进: 数据库配置假设如下: ![]() ![]() <connectionStrings> <add name="Conn" connectionString="Server=.;database=CQSpace;uid=sa;pwd=123456"/> <add name="CYQ" connectionString="Server=.;database=CQSpace;uid=sa;pwd=123456"/> < SPAN>connectionStrings> 操作类的实例方法: 方法一:默认取配置文件Conn的链接字符串 MAction action = new MAction(TableNames.CQ_BlogSet); 方法二:取自定义名称如CYQ的链接字符串: MAction action = new MAction(TableNames.CQ_BlogSet,"CYQ"); 方法三:直取链接字符串 MAction action = new MAction(TableNames.CQ_BlogSet,"Server=.;database=CQSpace;uid=sa;pwd=123456"); 接下来看看都有什么操作方法更新: 1:单条数据查询方法: 方式一:直接传ID ![]() ![]() MAction action = new MAction(TableNames.CQ_BlogSet); if (action.Fill(888)) { action.SetTo(lblAlbumType); action.Close(); } 方式二:传where条件 ![]() ![]() MAction action = new MAction(TableNames.CQ_BlogSet); if (action.Fill("Title='xxxx'")) { action.SetTo(lblAlbumType); action.Close(); } 2:数据删除: 方式一:先填充再删除 if (action.Fill(888)) { action.Delete(); action.Close(); } 方式二:根据ID删除 MAction action = new MAction(TableNames.CQ_Album); action.Delete(888); action.Close(); 方式三:根据条件删除 MAction action = new MAction(TableNames.CQ_Album); action.Delete("id>888"); action.Close(); 3:数据更新 方式一:先填充再更新 MAction action = new MAction(TableNames.CQ_Album); if (action.Fill(111)) { action.GetFrom(txtAlbumName); action.Update(); action.Close(); } 方式二:根据ID更新 MAction action = new MAction(TableNames.CQ_Album); action.GetFrom(txtAlbumName); action.Update(111); action.Close(); 方式三:根据条件更新 MAction action = new MAction(TableNames.CQ_Album); action.GetFrom(txtAlbumName); action.Update("id=299 or name='路过秋天'"); action.Close(); 4:数据列表查询和多表联合查询没变化,和上上节一致。 5:新增加计数查询: MAction action = new MAction(TableNames.CQ_BlogSet); lblAlbumType.Text = action.GetCount("id>2 and Name='路过秋天'").ToString(); action.Close(); 6:为了进一步隐藏索引取值与赋值而产生的Get与Set方法: 在上节的升级中,新增加的GetFrom与SetTo只能对控件赋值进行操作,如果我们只是需要取值,或设置值,中间没有控件呢? 在上节之前,我们只能又回到索引的方式取值了如: string albumType=action.Data[CQ_Album.AlbumName].Value.ToString(); 狂热升级之后:用上新加的Get方法取值,效果就变成了: string albumType = action.Get<string>(CQ_Album.AlbumName); 而Set方法赋值则为: action.Set(CQ_Album.AlbumName, "路过秋天";); 于是,对于取值与赋值,我们目前有3种方法可用了: 1:对控件型的:GetFrom与SetTo 2:对变量型的:Get与Set 3:保留的:索引数据/枚举与字段名(字符串)取值 OK,本节介绍点到为止,下节再开示例应用篇。欢迎使用与留言! 最后提供新版本V1.2下载:点击下载[大小:60K 没加密没混淆没限制,可放心使用,可直接用Reflector.exe查看源码] ![]() |
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.