Tag Archives: entities

C# Simple query Join between to entities 1..N

Havin to entities query the first one and filter by values on the first one and second one.


QueryExpression query = new QueryExpression
{
	EntityName = "h_licence",
	ColumnSet = new ColumnSet("h_regno", "h_rootregnumber", "h_revisionnumber", "h_libraryname"),
};

query.Criteria.AddCondition("h_licencestatus", ConditionOperator.Equal, 919780001);
query.Criteria.AddCondition("h_licencetype", ConditionOperator.In, 919780002, 953210002, 953210001, 919780001);
query.Criteria.AddCondition("h_substatus", ConditionOperator.NotIn, 4); //Exclude NFA
query.Criteria.AddCondition("statecode", ConditionOperator.Equal, "Active");

query.LinkEntities.Add(new LinkEntity("h_licence","h_licenceprofile","h_licenceprofileid","h_licenceprofileid",JoinOperator.Inner));
query.LinkEntities[0].LinkCriteria.AddCondition("h_enforcementriskcategory", ConditionOperator.Equal, os.Value);

return se.RetrieveMultiple(query);

Advertisements