Hello ,
I need to get an account ant some information from related entities .
it's ok when i try to get n:1 relationship but when i try to add n:n relationship it's not working .my code :
QueryExpression queryaccount = new QueryExpression(); queryaccount.EntityName = "account"; queryaccount.NoLock = true; queryaccount.ColumnSet = new ColumnSet(true); if (!string.IsNullOrEmpty(id)) queryaccount.Criteria.AddCondition("crm_identifiant", ConditionOperator.Equal, id); var linkCarteClient = new LinkEntity("account", "crm_carte_abonnement", "accountid", "crm_compteid", JoinOperator.LeftOuter); linkCarteClient.EntityAlias = "carte"; linkCarteClient.Columns = new ColumnSet(true); queryaccount.LinkEntities.Add(linkCarteClient); var linkAvoirAccount = new LinkEntity("account", "crm_avoir", "accountid", "crm_compteid", JoinOperator.LeftOuter); linkAvoirAccount.EntityAlias = "crm_avoir"; linkAvoirAccount.Columns = new ColumnSet(true); queryaccount.LinkEntities.Add(linkAvoirAccount); LinkEntity le = new LinkEntity(); le.LinkFromEntityName = "account"; le.LinkFromAttributeName = "accountid"; le.LinkToEntityName = "listmember"; le.LinkToAttributeName = "entityid"; LinkEntity le2 = new LinkEntity(); le2.LinkFromEntityName = "listmember"; le2.LinkFromAttributeName = "listid"; le2.LinkToEntityName = "list"; le2.LinkToAttributeName = "listid"; ///////// LinkEntity le3 = new LinkEntity(); le3.LinkFromEntityName = "list"; le3.LinkFromAttributeName = "listid"; le3.LinkToEntityName = "campaignitem"; le3.LinkToAttributeName = "entityid"; LinkEntity le4 = new LinkEntity(); le4.LinkFromEntityName = "campaignitem"; le4.LinkFromAttributeName = "campaignid"; le4.LinkToEntityName = "campaign"; le4.LinkToAttributeName = "campaignid"; le4.LinkEntities.Add(le3); le3.LinkEntities.Add(le2); le2.LinkEntities.Add(le); queryaccount.LinkEntities.Add(le); try { EntityCollection accounts = service.RetrieveMultiple(queryaccount); if (accounts.Entities != null && accounts.Entities.Count > 0) { Entity Account = accounts[0]; LogWebService.Log(ref _log, String.Format("Sortie de la fonction {0}", MethodBase.GetCurrentMethod()), LogWebService.LogLevel.Info); return Account; }
how to get the information about the marketing campaign ?
Thank you