惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

博客园 - neuhawk

偶最近没有搞.net了。 Silverlight 3 Beta Released(含详细的特点介绍,转载) c#关机时自动退出程序 (zt) Silverlight1-1正式更名为Silverlight2-0(转载) Silverlight 1.0正式发布了,并支持Linux Silverlight 1.0 RC and 1.1 alpha refresh 好消息:VS 2008 and .NET 3.5 Beta 2 发布了 Silverlight Rc 即将发布了 50个Silverlight应用程序. silverlight 数据绑定 Moonlight (silverlight for linux)只用了21天就开发出来了. 推荐一个强大的控件包(for RIA) 推荐一个非常cool的 silverlight教程 Mono Moonlight - Silverlight on Linux 即将发布 ASP.NET RSS Toolkit 2.0 Released(zt) Silverlight on Microsoft.com(转载) NET Framework 3.5 股市和房市。 推荐一个工具ViewState 分析工具
linq to sql 的动态条件查询方法
neuhawk · 2007-07-07 · via 博客园 - neuhawk

  最近园子里最热门的就是linq了,我也一直关注linq,看了很多相关的文章,也用vs 2008 beta1做了些例子,感觉linq太爽了,正如jjx所说的,nhibernate受到比较大的冲击。我也打算在项目中使用。
   然后我比较关注的是用linq替代现有的功能的方案,比如动态条件查询的功能,现在linq的动态查询方法有2种:
1、Anders Hejlsberg 推荐的,也就是在LINQ samples里的.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1752078&SiteID=1
代码:

var query =
    db.Customers.
    Where(
"City = @0 and Orders.Count >= @1""London"10).
    OrderBy(
"CompanyName").
    Select(
"new(CompanyName as Name, Phone)");



2、Wayward 也有另外的方案,详见
http://blogs.msdn.com/mattwar/archive/2006/05/10/594966.aspx
主要代码:

IQueryable q = ;

 

ParameterExpression p 
= Expression.Parameter(typeof(Customer), "c");

LambdaExpression predicate 
= 
    QueryExpression.Lambda(
"c.City = 'London'", p);

Expression where 
= QueryExpression.Where(q.Expression, predicate);

= q.CreateQuery(where);

我比较喜欢后者。

另外 Rico 针对linq to sql 做了一系列的性能分析,总体结论是linq性能不错,有些地方甚至比ado.net还要好。

DLinq (Linq to SQL) Performance (Part 4)
DLinq (Linq to SQL) Performance (Part 3)
DLinq (Linq to SQL) Performance (Part 2)
DLinq (Linq to SQL) Performance (Part 1)

DLinq (Linq to SQL) Performance (Part 4)的结果是:

no linq

       with linq

 

      select

  update

    insert

              original
select

   compiled
 select

  update

    compiled
    update

   insert

run 1 915.25 4.87 4.29 497.81 858.07 20.65 21.05 20.25
run 2 916.25 5.02 4.76 491.59 864.60 20.34 20.62 12.02
run 3 942.86 4.87 4.66 496.57 859.11 21.03 20.47 16.08
average 924.79 4.92 4.57 495.32 860.59 20.67 20.71 16.12

The units for all of the above are test iterations per second so bigger is better. 

         dlinq      nolinq          ratio
select 495.32 924.79 53.56%
compiled select 860.59 924.79 93.06%
update 20.67 4.92 420.19%   (DLinq is faster)
compiled update 20.71 4.92 421.00%   (DLinq is faster)
insert 16.12 4.57 352.66%   (DLinq is faster)