Skip to content

Query Extensions

Artem Grunin edited this page Mar 20, 2026 · 11 revisions

Query Extensions

Extensions for Microsoft.Xrm.Sdk.Query types.

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

EntityReference, KeyAttributeCollection and OptionSetValue are added in version 2.4.0
AliasedValue is added in version 2.5.0
Relationship and OptionSetValueCollection are added in version 2.11.0

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

QueryExpression query = new QueryExpression<Account>()
{
    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.

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);

SetTopCount

Introduced in version 2.7.0

Universal method to set Query top count value

public void SetTopCount(int count)

Clone this wiki locally