All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
实例:ASP.NET遍历配置文件的连接字符串_[Asp.Net教程]
ADO.NET2.0跟ADO.NET3.0的一些新特性简要介绍_.net资料_编程技术
使用,BasePage,来解决,GridView,执行,RenderControl,产生的错误_[Asp.Net教程]
Ajax清理缓存_[XML教程]
自定义PHP分页函数_php资料_编程技术
javascript的document和window对象详解_JavaScript技术_编程技术
asp.net生成静态页面_.net资料_编程技术
SQL,SERVER中一些对象的名称更改_[SQL,Server教程]
通过对PHP服务器端特性的配置加强PHP的安全_php资料_编程技术
ASP.NET技巧:access下的分页方案_[Asp.Net教程]
Reading number is top 10 pictures
红楼梦金陵十二钗(2)
人物写真-谢楠
BingBingFan apple dew point photo gallery3
农夫山泉变身记
The money of more than 100 countries and regions20
采访美女孙菲菲
Embarrassing things comic collection2
Beauty ZhiHuiLin1
A man's favorite things7
西班牙山村小景2
Download software ranking
网页特效实例大全
变速齿轮3.26
Prostitutes diary
Sora aoi - one of more PK
Tram sex maniac 2 (H) rar bag12
终极变速大师Speeder3.26
Tram sex maniac 2 (H) rar bag9
少妇苏霞全本
Unix video tutorial2
The cock of the Grosvenor LTD handsome
归海一刀 published in(发表于) 2014/1/30 1:02:26 Edit(编辑)
Linq,to,SQL,Dynamic,动态查询_[Asp.Net教程]

Linq,to,SQL,Dynamic,动态查询_[Asp.Net教程]

Linq to SQL Dynamic 动态查询_[Asp.Net教程]

在开发中我们常需要使用动态的条件来组合查询,scotte博客里提到了MS提供的一个动态查询类库Basic Dynamic LINQ C# Sample,这个可以给我们提供不少方便,但是给的示例实在太简单,实际当中我们很多不能像他这样用。


image


首先引入DynamicLibrary.cs,下面是我使用过程中的一些运行正确的用法(里面使用返回DataSet是因为对旧程序升级),我觉得写法很怪异,但是的确这样是正确的。


image


调用


image


最终生成的SQL语句


SELECT COUNT(*) AS [value]
FROM [dbo].[News] AS [t0]
WHERE ([t0].[NewsIsDeleted] IS NULL) AND ([t0].[NewsIsDisplay] = 1)
AND ([t0].[Newslanguages] = @p0) AND ([t0].[NewsIsHome] = 1) AND ([t0].[NewsIsTop] = 1)
-- @p0: Input NVarChar (Size = 8; Prec = 0; Scale = 0) [engbtest]
-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.21022.8


另外分享一个query to datareader的方法,有了datareader可以生成datatable,dataset等:


image


来源:http://www.cnblogs.com/cnblogsfans







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.