QueryableFilterUserControl.GetQueryable(IQueryable) Method


Gets the transformed IQueryable object from the source IQueryable object.

 abstract System::Linq::IQueryable ^ GetQueryable(System::Linq::IQueryable ^ source);
public abstract System.Linq.IQueryable GetQueryable (System.Linq.IQueryable source);
abstract member GetQueryable : System.Linq.IQueryable -> System.Linq.IQueryable
Public MustOverride Function GetQueryable (source As IQueryable) As IQueryable



The source IQueryable object.


The transformed IQueryable object from the source IQueryable object.


This method is implemented to transform the source IQueryable object into the target IQueryable object. Examples of IQueryable expressions that you might want to implement include order by, range, or search.

The following example shows how to implement the GetQueryable method for a Boolean filter that is derived from QueryableFilterUserControl.

public override IQueryable GetQueryable(IQueryable source) {  
    if (String.IsNullOrEmpty(DropDownList1.SelectedValue)) {  
        return source;  
    bool value = Convert.ToBoolean(DropDownList1.SelectedValue);  
    ParameterExpression parameterExpression =   
        Expression.Parameter(source.ElementType, "item");  
    Expression body = BuildQueryBody(  
        parameterExpression, value);  
    LambdaExpression lambda = Expression.Lambda(body,   
    MethodCallExpression whereCall = Expression.Call(  
        new Type[] { source.ElementType },   
        source.Expression, Expression.Quote(lambda));  
    return source.Provider.CreateQuery(whereCall);  
Public Overloads Overrides Function GetQueryable(ByVal source As IQueryable) As IQueryable   
    If [String].IsNullOrEmpty(DropDownList1.SelectedValue) Then   
        Return source   
    End If   
    Dim value As Boolean = Convert.ToBoolean(DropDownList1.SelectedValue)   
    Dim parameterExpression As ParameterExpression = Expression.Parameter(source.ElementType, "item")   
    Dim body As Expression = BuildQueryBody(parameterExpression, value)   
    Dim lambda As LambdaExpression = Expression.Lambda(body, parameterExpression)   
    Dim whereCall As MethodCallExpression = Expression.[Call](GetType(Queryable), "Where", _  
         New Type() {source.ElementType}, source.Expression, Expression.Quote(lambda))   
    Return source.Provider.CreateQuery(whereCall)   
End Function  


You must implement this method if you derive a control from QueryableFilterUserControl.

Applies to