Sunday, May 27, 2012

crm 2011- LINQ to retrieve associated cases

 var query1 = (from co in orgSrvContext.CreateQuery<Contact>()
                        join ca in orgSrvContext.CreateQuery<Incident>() on co.ContactId equals ca.CustomerId.Id
                        where co.MobilePhone == mobilenumber
                        select ca).ToList();
          Ins = new ObservableCollection<Incident>(query1);

To retrieve associated  records in plugin or custom workflow activity
   var  retrievedGunTransaction=   service.Retrieve(jmh_guntransaction.EntityLogicalName, context.PrimaryEntityId, new ColumnSet(true));
                  var gunTransaction = retrievedGunTransaction.ToEntity<jmh_guntransaction>();
                  var query = from trancationentry in orgServiceContext.CreateQuery<jmh_guntransactionentry>()
                              where trancationentry.jmh_guntransaction.Id == retrievedGunTransaction.Id
                              select trancationentry;

                  foreach (var transEntry in query)

No comments:

Post a Comment