Dynamics crm 加入一个活跃的政党领域

Dynamics crm 加入一个活跃的政党领域,dynamics-crm,dynamics-crm-2011,Dynamics Crm,Dynamics Crm 2011,我正在尝试在CRM 2011中查询数据,我需要加入一个ActivityParty。我似乎找不到任何关于它的好文件。以前有人这样做过吗。这是我目前的疑问: var linqQuery = (from r in gServiceContext.CreateQuery("campaignresponse") join c in gServiceContext.CreateQuery("contact") on ((EntityReference)r["customer

我正在尝试在CRM 2011中查询数据,我需要加入一个ActivityParty。我似乎找不到任何关于它的好文件。以前有人这样做过吗。这是我目前的疑问:

var linqQuery = (from r in gServiceContext.CreateQuery("campaignresponse")
                 join c in gServiceContext.CreateQuery("contact") on ((EntityReference)r["customer"]).Id equals c["contactid"] into opp
                 join a in gServiceContext,CreateQuery("lead") on ((EntityReference)r["customer"]).Id equals c["leadid"] into opp
                 from o in opp.DefaultIfEmpty()
                 where  ((EntityReference)r["new_distributorid"]).Id.Equals(lProfileProperty.PropertyValue) && ((OptionSetValue)r["new_distributorstatus"]).Equals("100000002")
                 select new
                  { }

因此,如果您查看查询,我尝试通过customer字段将contact实体和lead实体连接到CamapaignResponse,customer字段是ActivityParty字段。有什么办法吗?谢谢

我很难弄清楚您的查询应该如何工作,但是我可以告诉您,如果您使用SDK生成Linq实体,您将有一个更轻松的时间。然后,而不是

from r in gServiceContext.CreateQuery("campaignresponse") where ...
你可以直接写

gServiceContext.CampaignResponseSet
 .Where(cr => cr.property == value)
 .Select(cr => new {cr, cr.childObject});
等等。你也会有很强的打字能力和智能感知能力