As u all Know CRM "RetireveMultiple" fetches all the records . In a Scenario where you want to restrict it to retrieve the count of records according to the business rule, the below query would be used to restrict the count
public Guid retrievesite(int count)
{
QueryExpression qe = new QueryExpression("new_scans");
qe.PageInfo = new PagingInfo();
qe.PageInfo.Count = count;// pass number to which it should be restricted
qe.ColumnSet = new ColumnSet(true);
qe.Criteria.AddCondition("statuscode", ConditionOperator.Equal,100000003);
EntityCollection scans = _xrm.RetrieveMultiple(qe);
if (scans.Entities.Count > 0)
{
foreach (Entity site in scans.Entities)
{
string _sitename = site.Attributes["new_name"].ToString();
}
}
}
Thanks
public Guid retrievesite(int count)
{
QueryExpression qe = new QueryExpression("new_scans");
qe.PageInfo = new PagingInfo();
qe.PageInfo.Count = count;// pass number to which it should be restricted
qe.ColumnSet = new ColumnSet(true);
qe.Criteria.AddCondition("statuscode", ConditionOperator.Equal,100000003);
EntityCollection scans = _xrm.RetrieveMultiple(qe);
if (scans.Entities.Count > 0)
{
foreach (Entity site in scans.Entities)
{
string _sitename = site.Attributes["new_name"].ToString();
}
}
}
Thanks
No comments:
Post a Comment