xpo-devexpress-dot-xpo-dot-icustomcriteriaoperatorqueryable-dot-getcriteria-x28-devexpress-dot-data-dot-filtering-dot-criteriaoperator-x29.md
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
CriteriaOperator GetCriteria(
params CriteriaOperator[] operands
)
Function GetCriteria(
ParamArray operands As CriteriaOperator()
) As CriteriaOperator
| Name | Type | Description |
|---|---|---|
| operands | CriteriaOperator[] |
An array of CriteriaOperator containing function parameters.
|
| Type | Description |
|---|---|
| CriteriaOperator |
A CriteriaOperator object which corresponds to parameters passed as the operands.
|
The code below shows a sample GetCriteria implementation processing the operands.
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);
}
}
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