Back to Devexpress

XPQuery<T> Class

xpo-devexpress-dot-xpo-dot-xpquery-1.md

latest18.1 KB
Original Source

XPQuery<T> Class

A query that allows the construction of LINQ queries for persistent objects.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public class XPQuery<T> :
    XPQueryBase,
    IOrderedQueryable<T>,
    IEnumerable<T>,
    IEnumerable,
    IOrderedQueryable,
    IQueryable,
    IQueryable<T>,
    IQueryProvider
vb
Public Class XPQuery(Of T)
    Inherits XPQueryBase
    Implements IOrderedQueryable(Of T),
               IEnumerable(Of T),
               IEnumerable,
               IOrderedQueryable,
               IQueryable,
               IQueryable(Of T),
               IQueryProvider
csharp
public class XPQuery<T> :
    XPQueryBase,
    IOrderedQueryable<T>,
    IQueryable<T>,
    IEnumerable<T>,
    IEnumerable,
    IQueryable,
    IOrderedQueryable,
    IQueryProvider
vb
Public Class XPQuery(Of T)
    Inherits XPQueryBase
    Implements IOrderedQueryable(Of T),
               IQueryable(Of T),
               IEnumerable(Of T),
               IEnumerable,
               IQueryable,
               IOrderedQueryable,
               IQueryProvider

Type Parameters

Name
T

The following members return XPQuery<T> objects:

Remarks

To execute LINQ queries for persistent objects, perform the following steps:

  1. Create the XPQuery<T> instance of the required type.
  2. Write the required LINQ queries for the created XPQuery<T> instance.

The following code snippet illustrates this. It prints the last names of all the customers named “John”:

csharp
using DevExpress.Xpo;

//...

Session MainSession = new Session();
XPQuery<Customer> customersQuery = new XPQuery<Customer>(MainSession);

var customers = from c in customersQuery
                where c.Name == "John"
                select c;

foreach (Customer customer in customers)
    Console.WriteLine(customer.LastName);
vb
Imports DevExpress.Xpo

'...

Dim MainSession As New Session()
Dim customersQuery As XPQuery(Of Customer) = New XPQuery(Of Customer)(MainSession)

Dim customers = from c in customersQuery where c.Name = "John" select c

For Each customer As Customer In customers
    Console.WriteLine(customer.LastName)
Next customer

For more examples on using the XPQuery<T> class, refer to the LINQ to XPO article.

XPO LINQ expressions are processed on the database server side and only the requested objects are loaded into the application.

Inheritance

Object XPQueryBase XPQuery<T>

Extension Methods

Show 64 items

EnumerateAsync<T>(XPQueryExtensions.AsyncEnumerateCallback<T>)

EnumerateAsync<T>(XPQueryExtensions.AsyncEnumerateCallback)

EnumerateAsync<T>(CancellationToken)

CachedExpression<T, TResult>(Func<IQueryable<T>, TResult>)

CachedExpression<T, TArg1, TResult>(Func<IQueryable<T>, TArg1, TResult>, TArg1)

CachedExpression<T, TArg1, TArg2, TResult>(Func<IQueryable<T>, TArg1, TArg2, TResult>, TArg1, TArg2)

CachedExpression<T, TArg1, TArg2, TArg3, TResult>(Func<IQueryable<T>, TArg1, TArg2, TArg3, TResult>, TArg1, TArg2, TArg3)

CachedExpression<T, TArg1, TArg2, TArg3, TArg4, TResult>(Func<IQueryable<T>, TArg1, TArg2, TArg3, TArg4, TResult>, TArg1, TArg2, TArg3, TArg4)

CachedExpression<T, TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(Func<IQueryable<T>, TArg1, TArg2, TArg3, TArg4, TArg5, TResult>, TArg1, TArg2, TArg3, TArg4, TArg5)

ToListAsync<T>(CancellationToken)

ToArrayAsync<T>(CancellationToken)

ToDictionaryAsync<T, TKey>(Func<T, TKey>, CancellationToken)

ToDictionaryAsync<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>, IEqualityComparer<TKey>, CancellationToken)

ToDictionaryAsync<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>, CancellationToken)

ToDictionaryAsync<T, TKey>(Func<T, TKey>, IEqualityComparer<TKey>, CancellationToken)

ToLookupAsync<T, TKey>(Func<T, TKey>, CancellationToken)

ToLookupAsync<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>, CancellationToken)

ToLookupAsync<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>, IEqualityComparer<TKey>, CancellationToken)

ToLookupAsync<T, TKey>(Func<T, TKey>, IEqualityComparer<TKey>, CancellationToken)

ElementAtAsync<T>(Int32, CancellationToken)

ElementAtOrDefaultAsync<T>(Int32, CancellationToken)

CountAsync<T>(CancellationToken)

CountAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

LongCountAsync<T>(CancellationToken)

LongCountAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

ContainsAsync<T>(T, CancellationToken)

AnyAsync<T>(CancellationToken)

AnyAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

AllAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

FirstAsync<T>(CancellationToken)

FirstAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

FirstOrDefaultAsync<T>(CancellationToken)

FirstOrDefaultAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

LastAsync<T>(CancellationToken)

LastAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

LastOrDefaultAsync<T>(CancellationToken)

LastOrDefaultAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

SingleAsync<T>(CancellationToken)

SingleAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

SingleOrDefaultAsync<T>(CancellationToken)

SingleOrDefaultAsync<T>(Expression<Func<T, Boolean>>, CancellationToken)

MinAsync<T>(CancellationToken)

MinAsync<T, TResult>(Expression<Func<T, TResult>>, CancellationToken)

MaxAsync<T>(CancellationToken)

MaxAsync<T, TResult>(Expression<Func<T, TResult>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Int32>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Nullable<Int32>>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Int64>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Nullable<Int64>>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Decimal>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Nullable<Decimal>>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Single>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Nullable<Single>>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Double>>, CancellationToken)

SumAsync<T>(Expression<Func<T, Nullable<Double>>>, CancellationToken)

AverageAsync<T>(Expression<Func<T, Int32>>, CancellationToken)

AverageAsync<T>(Expression<Func<T, Int64>>, CancellationToken)

AverageAsync<T>(Expression<Func<T, Decimal>>, CancellationToken)

AverageAsync<T>(Expression<Func<T, Single>>, CancellationToken)

AverageAsync<T>(Expression<Func<T, Double>>, CancellationToken)

CustomAggregate<T>(String, Expression<Func<T, Object>>[])

CustomAggregateAsync<T>(String, Expression<Func<T, Object>>[])

CustomAggregateAsync<T>(String, Expression<Func<T, Object>>, CancellationToken)

CustomAggregateAsync<T>(String, Expression<Func<T, Object>>[], CancellationToken)

See Also

XPQuery<T> Members

LINQ to XPO

DevExpress.Xpo Namespace