This topic has not yet been rated - Rate this topic

QueryableFilterUserControl.GetQueryable Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets the transformed IQueryable object from the source IQueryable object.

Namespace:  System.Web.DynamicData
Assembly:  System.Web.DynamicData (in System.Web.DynamicData.dll)

public abstract IQueryable GetQueryable(
	IQueryable source
)

Parameters

source
Type: System.Linq.IQueryable
The source IQueryable object.

Return Value

Type: System.Linq.IQueryable
The transformed IQueryable object from the source IQueryable object.

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

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, 
        parameterExpression);
    MethodCallExpression whereCall = Expression.Call(
        typeof(Queryable), 
        "Where", 
        new Type[] { source.ElementType }, 
        source.Expression, Expression.Quote(lambda));
    return source.Provider.CreateQuery(whereCall);
}

.NET Framework

Supported in: 4.5, 4

Windows 8 Release Preview, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)