QueryableFilterUserControl.GetQueryable Method (IQueryable)
.NET Framework (current version)
Gets the transformed IQueryable object from the source IQueryable object.
Assembly: System.Web.DynamicData (in System.Web.DynamicData.dll)
Parameters
- source
-
Type:
System.Linq.IQueryable
The source IQueryable object.
Return Value
Type: System.Linq.IQueryableThe 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
Available since 4.0
Available since 4.0
Show: