QueryExpression与FetchXml CRM2011 [英] QueryExpression vs. FetchXml CRM2011

查看:131
本文介绍了QueryExpression与FetchXml CRM2011的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们发现,Linq for CRM 2011遭到了严重破坏-它似乎没有进行任何质量检查就加入了.一个指示符,如.Where(x => x =="b")的查询对提供者的破坏程度很严重,但是这个.Where(x =>"b" == x)可能不取决于诸如a之类的先前条件.加入声明.实际上,我不得不重写查询提供程序的某些部分,并享受在一起带来的好处.

We found out that Linq for CRM 2011 is horribly broken - it seems to have gotten in without any QA performed on it. An indicator as how badly broken the provider is a query like .Where(x => x== "b") works but this .Where(x => "b" == x) might not depending on some preceding condition like a join statement. I have actually had to rewrite parts of the query provider and am enjoying better luck with the crap I put together.

尽管这种情况无法解决,但仍然存在其他问题,我没有报酬为MS工作,因此我正在寻找替代方案.这两个是QueryExpression& FetchXml,如下所示: http://msdn.microsoft.com/zh-cn/library/gg334607.aspx

However this can't go on, there are still other issues and I'm not paid to to work for MS, so I'm looking at alternatives. These 2 came up QueryExpression & FetchXml as detailed here: http://msdn.microsoft.com/en-us/library/gg334607.aspx

谁能给我诚实,现实生活中使用QueryExpression与FetchXml的利弊?我想知道它们在性能,开发速度,健壮性和灵活性方面如何进行比较.

Can anyone give me an honest, real life pros and cons of using QueryExpression vs. FetchXml? I would like to know how they compare in terms of performance, development speed, robustness and flexibility.

推荐答案

在我看来,我通常会根据需求选择Linq或FetchXml.

In my opinion, I usually go for Linq or FetchXml depending for the requirements.

对于Linq:对于早期绑定,我喜欢使用Linq,因为它是强类型的,并且对开发速度有很大帮助,但是如上所述,它有其缺点.

For the Linq: In case for early-bound, I like using Linq because it's strongly typed and It helps much for development speed, but as you stated above, it has its disadvantages.

对于FetchXML:我真的很喜欢使用以下魔术语句:

For the FetchXML: I really love using this magic statement:

EntityCollection result = _serviceProxy.RetrieveMultiple(new FetchExpression(fetch2));

foreach (var c in result.Entities)
{
   System.Console.WriteLine(c.Attributes["name"]);
}

为什么?因为除了 aggregation grouping 之外,使用QueryExpression非常相似. 我唯一讨厌FetxhXML的地方是,它与Linq不同,难以构建.

Why? Because it's very similar of using the QueryExpression in addition of the aggregation and grouping. The only thing I hate about FetxhXML is that it's hard to build, unlike the Linq.

对于构建FetchXML查询,我必须打开高级查找",然后添加列,然后放置我的条件,依此类推,最后下载并复制到我的代码中,依此类推.

For building FetchXML queries, I have to open the Advanced-Find then add columns then put my criteria and so on, finally I download it and copy it into my code, and so on.

最后,FetchXML的限制最少.

Finally, the FetchXML has the least limitations among the others.

关于我尝试使用 StopWatch 对同一查询在Linq和FetchXML之间进行基准测试的性能,结果是FetchXML比Linq更快.

Regarding the performance I've tried to benchmark between Linq and FetchXML for same query using StopWatch, the result was FetchXML is faster than the Linq.

这篇关于QueryExpression与FetchXml CRM2011的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆