Back to Devexpress

XPQuery<T>.TransformExpression(Expression<Func<T, Boolean>>) Method

xpo-devexpress-dot-xpo-dot-xpquery-1-dot-transformexpression-x28-system-dot-linq-dot-expressions-dot-expression-system-dot-func-0-system-dot-boolean-x29.md

latest2.7 KB
Original Source

XPQuery<T>.TransformExpression(Expression<Func<T, Boolean>>) Method

Converts a lambda expression into an instance of the CriteriaOperator class descendant.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public CriteriaOperator TransformExpression(
    Expression<Func<T, bool>> expression
)
vb
Public Function TransformExpression(
    expression As Expression(Of Func(Of T, Boolean))
) As CriteriaOperator

Parameters

NameTypeDescription
expressionExpression<Func<T, Boolean>>

A lambda expression.

|

Returns

TypeDescription
CriteriaOperator

An instance of the CriteriaOperator class descendant that represents the lambda expression.

|

Example

In the following code snippet the customers collection will contain only the customers named “Bob”:

csharp
using DevExpress.Xpo;
using DevExpress.Data.Filtering;

//...

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

CriteriaOperator criteria = customersQuery.TransformExpression(c => c.Name == "Bob");

XPCollection<Customer> customers = new XPCollection<Customer>(MainSession);
customers.Criteria = criteria;
vb
Imports DevExpress.Xpo
Imports DevExpress.Data.Filtering

'...

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

Dim criteria As CriteriaOperator = customersQuery.TransformExpression(Function(c) c.Name = "Bob")

Dim customers As XPCollection(Of Customer) = New XPCollection(Of Customer)(MainSession)
customers.Criteria = criteria

See Also

XPQuery<T> Class

XPQuery<T> Members

DevExpress.Xpo Namespace