Many-to-many relationships between entities in version 1.0

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:53 PM by karolikl, version 1

Comments

No comments yet.