Back to Devexpress

ICustomCriteriaOperatorQueryable.GetCriteria(CriteriaOperator[]) Method

xpo-devexpress-dot-xpo-dot-icustomcriteriaoperatorqueryable-dot-getcriteria-x28-devexpress-dot-data-dot-filtering-dot-criteriaoperator-x29.md

latest3.9 KB
Original Source

ICustomCriteriaOperatorQueryable.GetCriteria(CriteriaOperator[]) Method

When implemented by a class, returns a CriteriaOperator equivalent to a custom function used in LINQ to XPO expressions, based on specified function parameters.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
CriteriaOperator GetCriteria(
    params CriteriaOperator[] operands
)
vb
Function GetCriteria(
    ParamArray operands As CriteriaOperator()
) As CriteriaOperator

Parameters

NameTypeDescription
operandsCriteriaOperator[]

An array of CriteriaOperator containing function parameters.

|

Returns

TypeDescription
CriteriaOperator

A CriteriaOperator object which corresponds to parameters passed as the operands.

|

Remarks

The code below shows a sample GetCriteria implementation processing the operands.

csharp
public class MyConcatFunction : ICustomFunctionOperatorBrowsable, ICustomFunctionOperatorFormattable,
    ICustomCriteriaOperatorQueryable {
    const string FunctionName = "MyConcat";
    // ...

    public CriteriaOperator GetCriteria(params CriteriaOperator[] operands) {            
        if(operands == null || operands.Length != 1 || !(operands[0] is MemberInitOperator)) 
            throw new ArgumentException(FunctionName);
        CriteriaOperatorCollection operandCollection = new CriteriaOperatorCollection();
        foreach(XPMemberAssignment operand in ((MemberInitOperator)operands[0]).Members) {
            operandCollection.Add(operand.Property);
        }
        return new FunctionOperator(FunctionName, operandCollection);
    }
}
vb
Public Class MyConcatFunction
    Implements ICustomFunctionOperatorBrowsable, ICustomFunctionOperatorFormattable, _
    ICustomCriteriaOperatorQueryable
    Private Const FunctionName As String = "MyConcat"
    ' ...

    Public Function GetCriteria(ParamArray ByVal operands() As CriteriaOperator) As CriteriaOperator
        If operands Is Nothing OrElse operands.Length <> 1 OrElse _
        Not(TypeOf operands(0) Is MemberInitOperator) Then
            Throw New ArgumentException(FunctionName)
        End If
        Dim operandCollection As New CriteriaOperatorCollection()
        For Each operand As XPMemberAssignment In (CType(operands(0), MemberInitOperator)).Members
            operandCollection.Add(operand.Property)
        Next operand
        Return New FunctionOperator(FunctionName, operandCollection)
    End Function
End Class

To see the entire example, see the How to: Implement Custom Functions and Criteria in LINQ to XPO.

See Also

ICustomCriteriaOperatorQueryable Interface

ICustomCriteriaOperatorQueryable Members

DevExpress.Xpo Namespace