locked
LinqToCrm and large queries RRS feed

  • Question

  • Hello fellow developpers,

    I was just asking myself if LINQ accelerated the queries to the CRM. I have some querie that required me to fetch with multiple pages in CRM 4. Can I simply swith those queries to LINQ or am I better to leave them in a multipage QueryExpression?

    Thank you!

    Mathieu

    Thursday, March 17, 2011 7:06 PM

Answers

  • The LINQ provider for CRM translates queries into QueryExpression, so they're really two sides of the same coin.

    To implement paging, simply use the Skip() and Take() extension methods:

    var contacts = xrm.contacts.Skip(50).Take(50);
    
    foreach (var contact in contacts)
    {
    	System.Diagnostics.Debug.Print(contact.fullname);
    }
    
    


    --pogo (pat)
    Thursday, March 17, 2011 9:53 PM
  • Hmmm... disappointing.

    My curiosity got the better of me, so I used Fiddler to see what actually gets sent to CRM with the above.  Unfortunately, the Paging element does not reflect the LINQ Skip() and Take() methods.

    All records are returned and the paging occurs at object level.  Not very useful if you're trying to reduce traffic and/or improve scalability. 


    --pogo (pat)
    Thursday, March 17, 2011 10:07 PM

All replies

  • The LINQ provider for CRM translates queries into QueryExpression, so they're really two sides of the same coin.

    To implement paging, simply use the Skip() and Take() extension methods:

    var contacts = xrm.contacts.Skip(50).Take(50);
    
    foreach (var contact in contacts)
    {
    	System.Diagnostics.Debug.Print(contact.fullname);
    }
    
    


    --pogo (pat)
    Thursday, March 17, 2011 9:53 PM
  • Hmmm... disappointing.

    My curiosity got the better of me, so I used Fiddler to see what actually gets sent to CRM with the above.  Unfortunately, the Paging element does not reflect the LINQ Skip() and Take() methods.

    All records are returned and the paging occurs at object level.  Not very useful if you're trying to reduce traffic and/or improve scalability. 


    --pogo (pat)
    Thursday, March 17, 2011 10:07 PM