public static EntityCollection GetInvoiceInSalesOrder(IOrganizationService ser, Guid salesorderid, ColumnSet columnset)
{
try
{
QueryExpression query = new QueryExpression()
{
EntityName = "invoice",
ColumnSet = columnset,
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("statecode",ConditionOperator.Equal,(int)InvoiceState.Active)
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="invoice",
LinkFromAttributeName="salesorderid",
LinkToEntityName = "salesorder",
LinkToAttributeName = "salesorderid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("salesorderid",ConditionOperator.Equal,salesorderid)
}
}
}
}
};
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
Hiç yorum yok:
Yorum Gönder