Skip to content

Query Extensions

Artem Grunin edited this page May 16, 2023 · 7 revisions

Query Extensions

Extensions for Microsoft.Xrm.Sdk.Query types.

GetPageNumber

Introduced in version 2.0.0

Universal method to get Query page number (FetchXML is supported).

public int GetPageNumber();

NextPage

Introduced in version 1.0.38

Universal method to set Query paging parameters to next page.

public void NextPage(string pagingCookie);

Closing a gap between late and early bound types

Introduced in version 1.2.0

Reflection is used to get entity or attribute logical name since version 1.3.0.
Logical names are cached to provide better performance

A set of extension methods and classes to support some expression-style techniques while using QueryExpression/QueryByAttribute classes.

QueryExpression query = new QueryExpression()
{
    ColumnSet = new ColumnSet<Account>(a => a.AccountNumber, a => a.Name),
    Criteria = new FilterExpression()
    {
        Conditions =
        {
            new ConditionExpression<Account>(a=> a.Name, ConditionOperator.BeginsWith, "Demo")
        }
    },
    Orders =
    {
        new OrderExpression<Account>(a=> a.AccountNumber, OrderType.Ascending)
    }
};

See blog post for details.