![]() | 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 数据框架 版本发布 V4.0
Platform for dynamic |
|
|
| #TopicOwner |
前言: 继正式发布V3.5到现在,刷的一下又1个半月过去了,而框架随着“秋色园-QBlog博客”一起成长,始终没停下脚步!!!
框架的主要成长在CYQ.Xml名称空间下成长的较多,好多细节的修改,没写什么日记记录,所以本文介绍的内容相对较少。 下面就介绍下V4.0中有日志记录部分的更新。 本次版本升级记录: 1:增加对Case语句的多数据库处理
2:MAction:开放DalType属性,允许获取当前操作的数据库类型 3:Pager:解决分页存储过程order by参数过长问题,参数加长 4:修正Pager的Access数据库分页,并使用3次top方式分页 5:修正bit类型对“1”的转换为true 6:修改自定义表语句查询无数据时,也返回表架构 7:Xml类里增加RSS功能 8:Proc 修正从sql切换到存储过程的bug 9:其它,随着秋色园一起成长优化的CYQ.Xml名称空间下的几个类。 以下对升级记录进行详解
一:Case语句的多数据库处理 在秋色园的开发中,又遇到一个需要用到Case语句的sql,因此,在思考良久之后,增加了Case语法的多语句处理,和之前语句一样的用法,关键字写成[#关键字],即可。 示例代码:节选自秋色园 string orderByKey = string.Format("{0}+[#CASE] [#WHEN] languageID={1} [#THEN] {2} [#ELSE] 0 [#END]", key, (int)Language.LanKey, (isHits ? 1000 : 100)); 说明: 同样的语句可以在Access、Mssql、Oracle中运行,如何解析就是框架内部的事情了。 如果需要变成普通的语句,只需要把[#]替换掉即可。 二:MAction:开放DalType属性,允许获取当前操作的数据库类型 通过增加的开放属性,使你在使用多数据库支持时,除了关键字解析方法之外,还可以使用分支语句。 示例代码: public void Demo() { using (MAction action = new MAction(TableNames.Blog_Content)) { switch (action.DalType) { case CYQ.Data.DAL.DalType.Access: //do access something break; case CYQ.Data.DAL.DalType.Oracle: //do Oracle something break; case CYQ.Data.DAL.DalType.Sql: //do Sql something break; } } } 三:Pager:解决分页存储过程order by参数过长问题,参数加长 原因解说:
框架内部提供的MSSQL的分页存储过程中,有一条原始的语句:cast(@OrderBy as nvarchar) 当order by 语句条件很复杂很长时,长度不够[默认好像是50个长度]将引发问题,因此, 框架内部长度改成400个长度如下:cast(@OrderBy as nvarchar(400)) 如果遇到了,请注意一下。 四:修正Pager的Access数据库分页,并使用3次top方式分页 之前的Access内部top max方式分页在使用自定义表且条件复杂的情况下,分页结果出现了些许偏差。
于是内部修正时使用了另两种分页语句:一种是not in分页,另一种是3次top。 在没有数据比较的情况下,使用了not in,并在秋色园中持续了一段时间。 前几天发现秋色园的分页速度有点慢,于是切到3次top查询分页,速度刷的一下上去了。 五:修正bit类型对“1”的转换为true 对于bit类型,有时候取/设值为是1或0,本次版本兼容数字型自动转化为true与false。 六:修改自定义表语句查询无数据时,也返回表架构 本次需求的来源始于秋色园的管理后台,因为后台使用传统的webform开发方式,在列表页上显示,当没有数据时,发现表头也没有。 于是增加在查询失败或无数据时,自动填充返回的MDataTable,使之结构完整。 七:Xml类里增加RSS功能 数据框架里的RSS类,比我之前发布的文章:实战篇-六十六行完成简洁的Rss输出类 要多出些许代码,因为考虑到和框架内部MDataTable的结合使用。 示例代码:节选自秋色园-完整RSS处理逻辑 public string GetRss(int cacheTime) { string cacheKey = "rss_" + DomainID; object outXml = Cache.Get(cacheKey); if (outXml != null) { return outXml.ToString(); } else { Rss rss = new Rss(); MutilLanguage seoDoc = new MutilLanguage(MapPath(Config.GlobalSkinPath + IDPage.SiteTitle),true,false); if (DomainID == 0)//系统Rss { rss.Set(seoDoc.Get(IDLang.sitetitle) + " - " + seoDoc.Get(IDLang.powerby), Config.HttpHost, seoDoc.Get(IDLang.description)); } else//用户Rss { string title =GetLangText(IsUserLang,DomainUser.Get if (string.IsNullOrEmpty(title)) { title = GetLangText(IsUserLang,DomainUser.Get } rss.Set(title + " - " + seoDoc.Get(IDLang.sitename), Config.HttpHost + "/" + Domain, DomainUser.Get } rss.SetImg(Config.HttpHost +Config.SystemTechSkinPath+"images/logo_"+seoDoc.LanKey.ToString().Substring(3)+".jpg", seoDoc.Get(IDLang.sitetitle) + " Logo", Config.HttpHost); string sql = CustomSQL.Rss + (DomainID > 0 ? " and UserID=" + DomainID : ""); using (MProc proc = new MProc(sql)) { rss.LoadData(proc.ExeMDataTable()); rss.SetMap(RssItemName.Title, null, Content.Title); rss.SetMap(RssItemName.Link, Config.HttpHost + "/{0}/article-detail-{1}", Users.UserName, Content.ID); rss.SetMap(RssItemName.Author, null, Users.NickName); rss.SetMap(RssItemName.PubDate, null, Content.CreateTime); rss.SetMap(RssItemName.Description, null, Content.Body); } string xml = rss.OutXml; Cache.Add(cacheKey, xml, null, cacheTime); return xml; } } 八:Proc 修正从sql切换到存储过程的bug 在使用MProc时,执行完存储过程之后,通过mproc.ResetProc("sql语句")切换到sql执行时,会提示失败。 本版本修正了这一小bug。 九:框架整体的优化 在秋以园的开发中,经过不断的重构及优化,框架内部会有更的细节修改,以便能适应更多的情况,但并不影响之前的功能。 由于考虑到CYQ.Xml方面应用的人不多,所以日志记录也相对较少。 不过重点说一句,在秋色园的整体应用中,CYQ.Xml名称空间下的类,是核心应用成员,希望大家伙空多关注下这方面的应用。 十:V4.0框架下载 下载地址:下载中心-秋色园 后续,会写一两篇CYQ.Xml方面的应用示例文章,欢迎大家关注下。 ![]() |
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.