Linq Performance in Dynamics CRM RRS feed

  • Question

  • I am using following Query from an external web application on Dynamics CRM Online to retrieve a particular record:

     var query = xrm.ContactSet
                        .Where(c => c.Telephone1.Equals(Name));

    This is taking nearly 41 seconds to complete the record retrieval, my internet speed is very good, what should I do to improve the performance to some practically efficient level ?

    • Edited by Absaar Monday, August 26, 2013 8:24 AM more good now
    Monday, August 26, 2013 8:17 AM

All replies

  • Hi Absaar,

    Try switching the LINQ statement to below and see if that improves performance:

    var query = (from c in xrm.ContactSet
                 where c.Telephone1 == Name
                 select c);

    Michael Palmer
    xRMPalmer     @MJFPalmer     Rockstar365

    Monday, August 26, 2013 8:34 AM
  • Thanx Palmer, this is pure awesomeness :)
    Monday, August 26, 2013 10:16 AM
  • Hi Absaar,

    The LINQ provider was probably downloading all your contacts and then filtering client side. You should also consider using LINQ projection to only select the attribute you want - this will increase performance even more:

    var query = (from c in xrm.ContactSet
                 where c.Telephone1 == Name
                 select new Contact{
                 FirstName = c.FirstName,
                 LastName = c.LastName

    This code will only return the first name and last name attributes (and the ID that is automatically included)



    Scott Durow
    Blog www.develop1.net    Follow Me
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Monday, August 26, 2013 10:36 AM