Compartilhar via


QueryableFilterUserControl.GetQueryable(IQueryable) Método

Definição

Obtém o objeto IQueryable transformado do objeto IQueryable de origem.

public:
 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

Parâmetros

source
IQueryable

O objeto IQueryable de origem.

Retornos

O objeto IQueryable transformado do objeto IQueryable de origem.

Exemplos

Esse método é implementado para transformar o objeto de origem IQueryable no objeto de destino IQueryable . Exemplos de IQueryable expressões que talvez você queira implementar incluem ordem por, intervalo ou pesquisa.

O exemplo a seguir mostra como implementar o GetQueryable método para um filtro booliano derivado de 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,   
        parameterExpression);  
    MethodCallExpression whereCall = Expression.Call(  
        typeof(Queryable),   
        "Where",   
        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  

Comentários

Você deverá implementar esse método se derivar um controle de QueryableFilterUserControl.

Aplica-se a