Why so quiet?

[For a moment I thought of the "Why so serious" scene of "The dark knight"... didn't you? ] 

Wondering why some CRM engineering members (PMs in particular) have been silent in the last couple of weeks? Well, because we are all heads down driving the next milestone of CRM5 and other interesting projects :). I’m really excited about all the things that we are doing and wish I could share them but alas I can’t, at least not now.

In the meantime and to gratify you for reading today’s post here is a quick tip that I got from a colleague PM (I still have to try it out myself but just looking at the code it make sense so I’ll just post it here anyway). Use LINQ to manipulate CRM queries. This is not a LINQ provider but a quick way to manipulate CRM data after you have retrieved them from the server (using fetchXml for example). If you are looking for a LINQ provider just search for “LINQ CRM” and you will find several libraries that you can reuse.

string xmlData = [FetchXMLResult]// this is coming back from a Fetch Request

System.IO.StringReader xmlSR = new System.IO.StringReader(xmlData);

Dataset ds = new Dataset();

ds.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);

 

DataTable contacts = ds.Tables["Contact"];

DataTable orders = ds.Tables["SalesOrderHeader"];

 

var query =

    from contact in contacts.AsEnumerable()

    from order in orders.AsEnumerable()

    where contact.Field<int>("ContactID") == order.Field<int>("ContactID")

        && order.Field<decimal>("TotalDue") < 500.00M

    select new

    {

        ContactID = contact.Field<int>("ContactID"),

        LastName = contact.Field<string>("LastName"),

        FirstName = contact.Field<string>("FirstName"),

        OrderID = order.Field<int>("SalesOrderID"),

        Total = order.Field<decimal>("TotalDue")

    };

 

   //do something with data