Many-to-many relationships between entities

Relationships between entities can either be one-to-many or many-to-many. An example of a many-to-many relationship is a Contact having several Salesorders, and a Salesorder can have several Contact persons.

In the case of many-to-many relationships you need to create a CrmManyToManyRelationshipController. The following example shows how to retrieve all SalesOrders of the Contact with contactid=guid.


CrmQuery query = new CrmQuery();
query.AddCondition(new CrmAttributeCriterion("contactid", guid, CrmConditionOperator.Equal));

CrmManyToManyRelationshipController<CrmContact, CrmOrder> manyToMany = factory.GetManyToManyRelationshipController<CrmContact, CrmOrder>();
List<CrmOrder> orders = manyToMany.Find(query);

Last edited Dec 3, 2012 at 1:56 PM by karolikl, version 4


No comments yet.