As I said in the other article, there are some exceptions from the usual many-to-many architecture – one of those exceptions are querying all marketing lists associated to an campaign In Microsoft CRM.
In this case you have to join with the CampaignItem table and check if the Logical Name of the entites matches.
If so, you will retrieve a full list of marketing lists.
EntityReference campaignref = campaign.ToEntityReference(); var lists = (from r in dataContext.CreateQuery<List>() join s in dataContext.CreateQuery<CampaignItem>() on r.ListId equals s.EntityId where s.EntityType == List.EntityLogicalName && s.CampaignId == campaignref select r.ListId);
From this point on you can work with the marketing lists, retrieve their members, add new members, remove members or copy a complete list.