Class QueryableExtensions
Provides extension methods to process DataSourceRequest.
Inheritance
Namespace: Telerik.DataSource.Extensions
Assembly: Telerik.DataSource.dll
Syntax
public static class QueryableExtensions : Object
Methods
Aggregate(IQueryable, IEnumerable<AggregateFunction>)
Calculates the results of given aggregates functions on a sequence of elements.
Declaration
public static AggregateResultCollection Aggregate(this IQueryable source, IEnumerable<AggregateFunction> aggregateFunctions)
Parameters
System.Linq.IQueryable
source
An System.Linq.IQueryable whose elements will be used for aggregate calculation. |
System.Collections.Generic.IEnumerable<AggregateFunction>
aggregateFunctions
The aggregate functions. |
Returns
AggregateResultCollection
Collection of AggregateResults calculated for each function. |
Count(IQueryable)
Returns the number of elements in a sequence.
Declaration
public static int Count(this IQueryable source)
Parameters
System.Linq.IQueryable
source
The System.Linq.IQueryable that contains the elements to be counted. |
Returns
System.Int32
The number of elements in the input sequence. |
Exceptions
System.ArgumentNullException
|
ElementAt(IQueryable, Int32)
Returns the element at a specified index in a sequence.
Declaration
public static object ElementAt(this IQueryable source, int index)
Parameters
System.Linq.IQueryable
source
An System.Linq.IQueryable to return an element from. |
System.Int32
index
The zero-based index of the element to retrieve. |
Returns
System.Object
The element at the specified position in |
Exceptions
System.ArgumentNullException
|
System.ArgumentOutOfRangeException
|
GroupBy(IQueryable, IEnumerable<GroupDescriptor>, Boolean)
Groups the elements of a sequence according to a specified groupDescriptors
.
Declaration
public static IQueryable GroupBy(this IQueryable source, IEnumerable<GroupDescriptor> groupDescriptors, bool includeItems = true)
Parameters
System.Linq.IQueryable
source
An System.Linq.IQueryable whose elements to group. |
System.Collections.Generic.IEnumerable<GroupDescriptor>
groupDescriptors
The group descriptors used for grouping. |
System.Boolean
includeItems
|
Returns
System.Linq.IQueryable
An System.Linq.IQueryable with IGroup items, whose elements contains a sequence of objects and a key. |
GroupBy(IQueryable, LambdaExpression)
Groups the elements of a sequence according to a specified key selector function.
Declaration
public static IQueryable GroupBy(this IQueryable source, LambdaExpression keySelector)
Parameters
System.Linq.IQueryable
source
An System.Linq.IQueryable whose elements to group. |
System.Linq.Expressions.LambdaExpression
keySelector
A function to extract the key for each element. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable with System.Linq.IGrouping`2 items, whose elements contains a sequence of objects and a key. |
GroupBy(IQueryable, IQueryable, IEnumerable<GroupDescriptor>, Boolean)
Declaration
public static IQueryable GroupBy(this IQueryable source, IQueryable notPagedData, IEnumerable<GroupDescriptor> groupDescriptors, bool includeItems = true)
Parameters
System.Linq.IQueryable
source
|
System.Linq.IQueryable
notPagedData
|
System.Collections.Generic.IEnumerable<GroupDescriptor>
groupDescriptors
|
System.Boolean
includeItems
|
Returns
System.Linq.IQueryable
|
OrderBy(IQueryable, LambdaExpression)
Sorts the elements of a sequence in ascending order according to a key.
Declaration
public static IQueryable OrderBy(this IQueryable source, LambdaExpression keySelector)
Parameters
System.Linq.IQueryable
source
A sequence of values to order. |
System.Linq.Expressions.LambdaExpression
keySelector
A function to extract a key from an element. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable whose elements are sorted according to a key. |
OrderBy(IQueryable, LambdaExpression, Nullable<ListSortDirection>)
Calls OrderBy(IQueryable, LambdaExpression)
or OrderByDescending(IQueryable, LambdaExpression) depending on the sortDirection
.
Declaration
public static IQueryable OrderBy(this IQueryable source, LambdaExpression keySelector, Nullable<ListSortDirection> sortDirection)
Parameters
System.Linq.IQueryable
source
The source. |
System.Linq.Expressions.LambdaExpression
keySelector
The key selector. |
System.Nullable<ListSortDirection>
sortDirection
The sort direction. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable whose elements are sorted according to a key. |
OrderByDescending(IQueryable, LambdaExpression)
Sorts the elements of a sequence in descending order according to a key.
Declaration
public static IQueryable OrderByDescending(this IQueryable source, LambdaExpression keySelector)
Parameters
System.Linq.IQueryable
source
A sequence of values to order. |
System.Linq.Expressions.LambdaExpression
keySelector
A function to extract a key from an element. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable whose elements are sorted in descending order according to a key. |
Page(IQueryable, Int32, Int32)
Pages through the elements of a sequence until the specified
pageIndex
using pageSize
.
Declaration
public static IQueryable Page(this IQueryable source, int pageIndex, int pageSize)
Parameters
System.Linq.IQueryable
source
A sequence of values to page. |
System.Int32
pageIndex
Index of the page. |
System.Int32
pageSize
Size of the page. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable whose elements are at the specified |
Select(IQueryable, LambdaExpression)
Projects each element of a sequence into a new form.
Declaration
public static IQueryable Select(this IQueryable source, LambdaExpression selector)
Parameters
System.Linq.IQueryable
source
A sequence of values to project. |
System.Linq.Expressions.LambdaExpression
selector
A projection function to apply to each element. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable whose elements are the result of invoking a
projection selector on each element of |
Skip(IQueryable, Int32)
Bypasses a specified number of elements in a sequence and then returns the remaining elements.
Declaration
public static IQueryable Skip(this IQueryable source, int count)
Parameters
System.Linq.IQueryable
source
An System.Linq.IQueryable to return elements from. |
System.Int32
count
The number of elements to skip before returning the remaining elements. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable that contains elements that occur after the specified index in the input sequence. |
Exceptions
System.ArgumentNullException
|
Sort(IQueryable, IEnumerable<SortDescriptor>)
Sorts the elements of a sequence using the specified sort descriptors.
Declaration
public static IQueryable Sort(this IQueryable source, IEnumerable<SortDescriptor> sortDescriptors)
Parameters
System.Linq.IQueryable
source
A sequence of values to sort. |
System.Collections.Generic.IEnumerable<SortDescriptor>
sortDescriptors
The sort descriptors used for sorting. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable whose elements are sorted according to a |
Take(IQueryable, Int32)
Returns a specified number of contiguous elements from the start of a sequence.
Declaration
public static IQueryable Take(this IQueryable source, int count)
Parameters
System.Linq.IQueryable
source
The sequence to return elements from. |
System.Int32
count
The number of elements to return. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable that contains the specified number
of elements from the start of |
Exceptions
System.ArgumentNullException
|
ToDataSourceResult(IEnumerable, DataSourceRequest)
Applies paging, sorting, filtering and grouping using the information from the DataSourceRequest object. If the collection is already paged, the method returns an empty result.
Declaration
public static DataSourceResult ToDataSourceResult(this IEnumerable enumerable, DataSourceRequest request)
Parameters
System.Collections.IEnumerable
enumerable
An instance of System.Collections.IEnumerable. |
DataSourceRequest
request
An instance of DataSourceRequest. |
Returns
DataSourceResult
A DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied. |
ToDataSourceResult(DataTable, DataSourceRequest)
Applies paging, sorting, filtering and grouping using the information from the DataSourceRequest object. If the collection is already paged, the method returns an empty resullt.
Declaration
public static DataSourceResult ToDataSourceResult(this DataTable dataTable, DataSourceRequest request)
Parameters
System.Data.DataTable
dataTable
An instance of System.Data.DataTable. |
DataSourceRequest
request
An instance of DataSourceRequest. |
Returns
DataSourceResult
A DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied. |
ToDataSourceResult(IQueryable, DataSourceRequest)
Applies paging, sorting, filtering and grouping using the information from the DataSourceRequest object. If the collection is already paged, the method returns an empty result.
Declaration
public static DataSourceResult ToDataSourceResult(this IQueryable queryable, DataSourceRequest request)
Parameters
System.Linq.IQueryable
queryable
An instance of System.Linq.IQueryable. |
DataSourceRequest
request
An instance of DataSourceRequest. |
Returns
DataSourceResult
A DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied. |
ToDataSourceResult<TModel, TResult>(IEnumerable<TModel>, DataSourceRequest, Func<TModel, TResult>)
Declaration
public static DataSourceResult ToDataSourceResult<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters
System.Collections.Generic.IEnumerable<TModel>
enumerable
|
DataSourceRequest
request
|
System.Func<TModel, TResult>
selector
|
Returns
DataSourceResult
|
Type Parameters
TModel
|
TResult
|
ToDataSourceResult<TModel, TResult>(IQueryable<TModel>, DataSourceRequest, Func<TModel, TResult>)
Declaration
public static DataSourceResult ToDataSourceResult<TModel, TResult>(this IQueryable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters
System.Linq.IQueryable<TModel>
enumerable
|
DataSourceRequest
request
|
System.Func<TModel, TResult>
selector
|
Returns
DataSourceResult
|
Type Parameters
TModel
|
TResult
|
ToDataSourceResultAsync(IEnumerable, DataSourceRequest)
Applies paging, sorting, filtering and grouping using the information from the DataSourceRequest object. If the collection is already paged, the method returns an empty result.
Declaration
public static Task<DataSourceResult> ToDataSourceResultAsync(this IEnumerable enumerable, DataSourceRequest request)
Parameters
System.Collections.IEnumerable
enumerable
An instance of System.Collections.IEnumerable. |
DataSourceRequest
request
An instance of DataSourceRequest. |
Returns
System.Threading.Tasks.Task<DataSourceResult>
A Task of DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation. |
ToDataSourceResultAsync(DataTable, DataSourceRequest)
Applies paging, sorting, filtering and grouping using the information from the DataSourceRequest object. If the collection is already paged, the method returns an empty resullt.
Declaration
public static Task<DataSourceResult> ToDataSourceResultAsync(this DataTable dataTable, DataSourceRequest request)
Parameters
System.Data.DataTable
dataTable
An instance of System.Data.DataTable. |
DataSourceRequest
request
An instance of DataSourceRequest. |
Returns
System.Threading.Tasks.Task<DataSourceResult>
A Task of DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation. |
ToDataSourceResultAsync(IQueryable, DataSourceRequest)
Applies paging, sorting, filtering and grouping using the information from the DataSourceRequest object. If the collection is already paged, the method returns an empty result.
Declaration
public static Task<DataSourceResult> ToDataSourceResultAsync(this IQueryable queryable, DataSourceRequest request)
Parameters
System.Linq.IQueryable
queryable
An instance of System.Linq.IQueryable. |
DataSourceRequest
request
An instance of DataSourceRequest. |
Returns
System.Threading.Tasks.Task<DataSourceResult>
A Task of DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation. |
ToDataSourceResultAsync<TModel, TResult>(IEnumerable<TModel>, DataSourceRequest, Func<TModel, TResult>)
Declaration
public static Task<DataSourceResult> ToDataSourceResultAsync<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters
System.Collections.Generic.IEnumerable<TModel>
enumerable
|
DataSourceRequest
request
|
System.Func<TModel, TResult>
selector
|
Returns
System.Threading.Tasks.Task<DataSourceResult>
|
Type Parameters
TModel
|
TResult
|
ToDataSourceResultAsync<TModel, TResult>(IQueryable<TModel>, DataSourceRequest, Func<TModel, TResult>)
Declaration
public static Task<DataSourceResult> ToDataSourceResultAsync<TModel, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters
System.Linq.IQueryable<TModel>
queryable
|
DataSourceRequest
request
|
System.Func<TModel, TResult>
selector
|
Returns
System.Threading.Tasks.Task<DataSourceResult>
|
Type Parameters
TModel
|
TResult
|
Union(IQueryable, IQueryable)
Produces the set union of two sequences by using the default equality comparer.
Declaration
public static IQueryable Union(this IQueryable source, IQueryable second)
Parameters
System.Linq.IQueryable
source
An System.Linq.IQueryable whose distinct elements form the first set for the union. |
System.Linq.IQueryable
second
An System.Linq.IQueryable whose distinct elements form the first set for the union. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable that contains the elements from both input sequences, excluding duplicates. |
Exceptions
System.ArgumentNullException
|
Where(IQueryable, IEnumerable<IFilterDescriptor>)
Filters a sequence of values based on a collection of IFilterDescriptor.
Declaration
public static IQueryable Where(this IQueryable source, IEnumerable<IFilterDescriptor> filterDescriptors)
Parameters
System.Linq.IQueryable
source
The source. |
System.Collections.Generic.IEnumerable<IFilterDescriptor>
filterDescriptors
The filter descriptors. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable that contains elements from the input sequence
that satisfy the conditions specified by each filter descriptor in |
Where(IQueryable, Expression)
Filters a sequence of values based on a predicate.
Declaration
public static IQueryable Where(this IQueryable source, Expression predicate)
Parameters
System.Linq.IQueryable
source
An System.Linq.IQueryable to filter. |
System.Linq.Expressions.Expression
predicate
A function to test each element for a condition. |
Returns
System.Linq.IQueryable
An System.Linq.IQueryable that contains elements from the input sequence
that satisfy the condition specified by |