New to Telerik UI for BlazorStart a free 30-day trial

Provides extension methods to process DataSourceRequest.

Definition

Namespace:Telerik.DataSource.Extensions

Assembly:Telerik.DataSource.dll

Syntax:

C#
public static class QueryableExtensions

Inheritance: objectQueryableExtensions

Methods

Calculates the results of given aggregates functions on a sequence of elements.

C#
public static AggregateResultCollection Aggregate(this IQueryable source, IEnumerable<AggregateFunction> aggregateFunctions)
Parameters:sourceIQueryable

An IQueryable whose elements will be used for aggregate calculation.

aggregateFunctionsIEnumerable<AggregateFunction>

The aggregate functions.

Returns:

AggregateResultCollection

Collection of AggregateResults calculated for each function.

Returns the number of elements in a sequence.

C#
public static int Count(this IQueryable source)
Parameters:sourceIQueryable

The IQueryable that contains the elements to be counted.

Returns:

int

The number of elements in the input sequence.

Exceptions:

ArgumentNullException

source is null.

Returns the element at a specified index in a sequence.

C#
public static object ElementAt(this IQueryable source, int index)
Parameters:sourceIQueryable

An IQueryable to return an element from.

indexint

The zero-based index of the element to retrieve.

Returns:

object

The element at the specified position in source.

Exceptions:

ArgumentNullException

source is null.

ArgumentOutOfRangeException

index is less than zero.

Groups the elements of a sequence according to a specified groupDescriptors.

C#
public static IQueryable GroupBy(this IQueryable source, IEnumerable<GroupDescriptor> groupDescriptors, bool includeItems = true)
Parameters:sourceIQueryable

An IQueryable whose elements to group.

groupDescriptorsIEnumerable<GroupDescriptor>

The group descriptors used for grouping.

includeItemsbool
Returns:

IQueryable

An IQueryable with IGroup items, whose elements contains a sequence of objects and a key.

C#
public static IQueryable GroupBy(this IQueryable source, IQueryable notPagedData, IEnumerable<GroupDescriptor> groupDescriptors, bool includeItems = true)
Parameters:sourceIQueryablenotPagedDataIQueryablegroupDescriptorsIEnumerable<GroupDescriptor>includeItemsboolReturns:

IQueryable

Groups the elements of a sequence according to a specified key selector function.

C#
public static IQueryable GroupBy(this IQueryable source, LambdaExpression keySelector)
Parameters:sourceIQueryable

An IQueryable whose elements to group.

keySelectorLambdaExpression

A function to extract the key for each element.

Returns:

IQueryable

An IQueryable with IGrouping<TKey, TElement> items, whose elements contains a sequence of objects and a key.

C#
public static IQueryable OrderBy(this IQueryable source, LambdaExpression keySelector, ListSortDirection? sortDirection)
Parameters:sourceIQueryable

The source.

keySelectorLambdaExpression

The key selector.

sortDirectionListSortDirection?

The sort direction.

Returns:

IQueryable

An IQueryable whose elements are sorted according to a key.

Sorts the elements of a sequence in ascending order according to a key.

C#
public static IQueryable OrderBy(this IQueryable source, LambdaExpression keySelector)
Parameters:sourceIQueryable

A sequence of values to order.

keySelectorLambdaExpression

A function to extract a key from an element.

Returns:

IQueryable

An IQueryable whose elements are sorted according to a key.

Sorts the elements of a sequence in descending order according to a key.

C#
public static IQueryable OrderByDescending(this IQueryable source, LambdaExpression keySelector)
Parameters:sourceIQueryable

A sequence of values to order.

keySelectorLambdaExpression

A function to extract a key from an element.

Returns:

IQueryable

An IQueryable whose elements are sorted in descending order according to a key.

Pages through the elements of a sequence until the specified pageIndex using pageSize.

C#
public static IQueryable Page(this IQueryable source, int pageIndex, int pageSize)
Parameters:sourceIQueryable

A sequence of values to page.

pageIndexint

Index of the page.

pageSizeint

Size of the page.

Returns:

IQueryable

An IQueryable whose elements are at the specified pageIndex.

Projects each element of a sequence into a new form.

C#
public static IQueryable Select(this IQueryable source, LambdaExpression selector)
Parameters:sourceIQueryable

A sequence of values to project.

selectorLambdaExpression

A projection function to apply to each element.

Returns:

IQueryable

An IQueryable whose elements are the result of invoking a projection selector on each element of source.

Bypasses a specified number of elements in a sequence and then returns the remaining elements.

C#
public static IQueryable Skip(this IQueryable source, int count)
Parameters:sourceIQueryable

An IQueryable to return elements from.

countint

The number of elements to skip before returning the remaining elements.

Returns:

IQueryable

An IQueryable that contains elements that occur after the specified index in the input sequence.

Exceptions:

ArgumentNullException

source is null.

Sorts the elements of a sequence using the specified sort descriptors.

C#
public static IQueryable Sort(this IQueryable source, IEnumerable<SortDescriptor> sortDescriptors)
Parameters:sourceIQueryable

A sequence of values to sort.

sortDescriptorsIEnumerable<SortDescriptor>

The sort descriptors used for sorting.

Returns:

IQueryable

An IQueryable whose elements are sorted according to a sortDescriptors.

Returns a specified number of contiguous elements from the start of a sequence.

C#
public static IQueryable Take(this IQueryable source, int count)
Parameters:sourceIQueryable

The sequence to return elements from.

countint

The number of elements to return.

Returns:

IQueryable

An IQueryable that contains the specified number of elements from the start of source.

Exceptions:

ArgumentNullException

source is null.

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.

C#
public static DataSourceResult ToDataSourceResult(this DataTable dataTable, DataSourceRequest request)
Parameters:dataTableDataTable

An instance of DataTable.

requestDataSourceRequest

An instance of DataSourceRequest.

Returns:

DataSourceResult

A DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied.

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.

C#
public static DataSourceResult ToDataSourceResult(this IEnumerable enumerable, DataSourceRequest request)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

Returns:

DataSourceResult

A DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied.

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.

C#
public static DataSourceResult ToDataSourceResult(this IQueryable queryable, DataSourceRequest request)
Parameters:queryableIQueryable

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

Returns:

DataSourceResult

A DataSourceResult object, which contains the processed data after paging, sorting, filtering and grouping are applied.

C#
public static DataSourceResult ToDataSourceResult<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>requestDataSourceRequestselectorFunc<TModel, TResult>Returns:

DataSourceResult

C#
public static DataSourceResult ToDataSourceResult<TModel, TResult>(this IQueryable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIQueryable<TModel>requestDataSourceRequestselectorFunc<TModel, TResult>Returns:

DataSourceResult

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.

C#
public static Task<DataSourceResult> ToDataSourceResultAsync(this DataTable dataTable, DataSourceRequest request)
Parameters:dataTableDataTable

An instance of DataTable.

requestDataSourceRequest

An instance of DataSourceRequest.

Returns:

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.

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.

C#
public static Task<DataSourceResult> ToDataSourceResultAsync(this IEnumerable enumerable, DataSourceRequest request)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

Returns:

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.

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.

C#
public static Task<DataSourceResult> ToDataSourceResultAsync(this IQueryable queryable, DataSourceRequest request)
Parameters:queryableIQueryable

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

Returns:

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.

C#
public static Task<DataSourceResult> ToDataSourceResultAsync<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>requestDataSourceRequestselectorFunc<TModel, TResult>Returns:

Task<DataSourceResult>

C#
public static Task<DataSourceResult> ToDataSourceResultAsync<TModel, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>requestDataSourceRequestselectorFunc<TModel, TResult>Returns:

Task<DataSourceResult>

Produces the set union of two sequences by using the default equality comparer.

C#
public static IQueryable Union(this IQueryable source, IQueryable second)
Parameters:sourceIQueryable

An IQueryable whose distinct elements form the first set for the union.

secondIQueryable

An IQueryable whose distinct elements form the first set for the union.

Returns:

IQueryable

An IQueryable that contains the elements from both input sequences, excluding duplicates.

Exceptions:

ArgumentNullException

source is null.

Filters a sequence of values based on a predicate.

C#
public static IQueryable Where(this IQueryable source, Expression predicate)
Parameters:sourceIQueryable

An IQueryable to filter.

predicateExpression

A function to test each element for a condition.

Returns:

IQueryable

An IQueryable that contains elements from the input sequence that satisfy the condition specified by predicate.

Filters a sequence of values based on a collection of IFilterDescriptor.

C#
public static IQueryable Where(this IQueryable source, IEnumerable<IFilterDescriptor> filterDescriptors)
Parameters:sourceIQueryable

The source.

filterDescriptorsIEnumerable<IFilterDescriptor>

The filter descriptors.

Returns:

IQueryable

An IQueryable that contains elements from the input sequence that satisfy the conditions specified by each filter descriptor in filterDescriptors.