QueryExpression vs. FetchXml CRM2011

前端 未结 4 809
太阳男子
太阳男子 2020-12-30 14:47

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

4条回答
  •  没有蜡笔的小新
    2020-12-30 15:45

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

    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.

    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"]);
    }
    

    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.

    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.

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

    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.

提交回复
热议问题