New to Telerik UI for ASP.NET Core? Start a free 30-day trial

Provides extension methods to process DataSourceRequest.

Definition

Namespace:Kendo.Mvc.Extensions

Assembly:Kendo.Mvc.dll

Syntax:

C#
public static class QueryableExtensions

Inheritance: objectQueryableExtensions

Inherited Members object.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()...

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.Aggregate(request.Aggregates.SelectMany(a =&gt; a.Aggregates));

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.GroupBy(request.Groups);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

var element = orders.ElementAt(2);
element.ContactName = "New Name";

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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

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

An IQueryable whose elements to group.

groupDescriptorsIEnumerable<GroupDescriptor>

The group descriptors used for grouping.

includeItemsbool

Whether to include individual items in the groups.

Returns:

IQueryable

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

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.GroupBy(request.Groups);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

Groups the elements of a sequence according to a specified groupDescriptors and allows including or excluding the parents.

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

An IQueryable whose elements to group.

notPagedDataIQueryable

The not paged data.

groupDescriptorsIEnumerable<GroupDescriptor>

The group descriptors used for grouping.

includeItemsbool

The condition for including the parents.

Returns:

IQueryable

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

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.GroupBy(orders, request.Groups, true);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.GroupBy(x =&gt; x.ContactName);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}
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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

Expression&lt;Func&lt;OrderViewModel, string&gt;&gt; e = (x) =&gt; x.ContactName;
orders.OrderBy(e, sortDirection: ListSortDirection.Descending);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.OrderBy(x =&gt; x.ContactName);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.OrderByDescending(x =&gt; x.ContactName);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.Page(request.Page, request.PageSize);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.Select(x =&gt; x.ContactName);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count() - 10;

orders.Skip(10);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
var total = orders.Count();

orders.Sort(request.Sorts);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
orders.Take(1000);

var result = new DataSourceResult()
{
Data = orders,
Total = 1000
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = GetOrders().ToDataSourceResult(request);
return Json(result);
}

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, ModelStateDictionary modelState)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

DataSourceResult

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

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = GetOrders().ToDataSourceResult(request, ModelState);
return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = GetOrders().ToDataSourceResult(request);
return Json(result);
}

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, ModelStateDictionary modelState)
Parameters:queryableIQueryable

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

DataSourceResult

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

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResult(request, ModelState);
return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = GetOrders().ToDataSourceResult(request);
return Json(result);
}

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<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

DataSourceResult

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

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = GetOrders().ToDataSourceResult&lt;OrderViewModel, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
});
return Json(result);
}

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<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

DataSourceResult

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

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = GetOrders().ToDataSourceResult&lt;OrderViewModel, Order&gt;(request, ModelState, x =&gt; new Order()
{
OrderID = x.OrderID
});
return Json(result);
}

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<TModel, TResult>(this IQueryable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

DataSourceResult

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

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = GetOrders().ToDataSourceResult&lt;OrderViewModel, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
});
return Json(result);
}

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<TModel, TResult>(this IQueryable<TModel> enumerable, DataSourceRequest request, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:enumerableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

DataSourceResult

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

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResult&lt;OrderViewModel, Order&gt;(request, ModelState, x =&gt; new Order()
{
OrderID = x.OrderID
});
return Json(result);
}

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, CancellationToken cancellationToken)
Parameters:dataTableDataTable

An instance of DataTable.

requestDataSourceRequest

An instance of DataSourceRequest.

cancellationTokenCancellationToken

An instance of CancellationToken.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync(request, token);
return Json(result);
}

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResultAsync(request);
return Json(result);
}

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, CancellationToken cancellation)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

cancellationCancellationToken

An instance of CancellationToken.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync(request, token);
return Json(result);
}

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, ModelStateDictionary modelState, CancellationToken cancellation)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

cancellationCancellationToken

An instance of CancellationToken.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync(request, ModelState, token);
return Json(result);
}

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, ModelStateDictionary modelState)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResultAsync(request, ModelState);
return Json(result);
}

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResultAsync(request);
return Json(result);
}

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, CancellationToken cancellationToken)
Parameters:queryableIQueryable

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

cancellationTokenCancellationToken

An instance of CancellationToken.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync(request, token);
return Json(result);
}

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, ModelStateDictionary modelState, CancellationToken cancellationToken)
Parameters:queryableIQueryable

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

cancellationTokenCancellationToken

An instance of CancellationToken.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync&lt;OrderViewModel, ModelState, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
}, token);
return Json(result);
}

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, ModelStateDictionary modelState)
Parameters:queryableIQueryable

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResultAsync(request, ModelState);
return Json(result);
}

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResultAsync(request);
return Json(result);
}

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<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync&lt;OrderViewModel, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
}, token);
return Json(result);
}

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<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResultAsync&lt;OrderViewModel, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
});
return Json(result);
}

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<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, ModelStateDictionary modelState, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync&lt;OrderViewModel, ModelState, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
}, token);
return Json(result);
}

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<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResult&lt;OrderViewModel, Order&gt;(request, ModelState, x =&gt; new Order()
{
OrderID = x.OrderID
});
return Json(result);
}

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<TModel, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>requestDataSourceRequestselectorFunc<TModel, TResult>cancellationTokenCancellationTokenReturns:

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync&lt;OrderViewModel, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
}, token);
return Json(result);
}

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<TModel, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>requestDataSourceRequestselectorFunc<TModel, TResult>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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResultAsync&lt;OrderViewModel, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
});
return Json(result);
}

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<TModel, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, ModelStateDictionary modelState, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetOrders().ToDataSourceResultAsync&lt;OrderViewModel, ModelState, Order&gt;(request, x =&gt; new Order()
{
OrderID = x.OrderID
}, token);
return Json(result);
}

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<TModel, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

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.

Example:
C#
public async Task&lt;IActionResult&gt; Orders_Read([DataSourceRequest] DataSourceRequest request)
{
var result = await GetOrders().ToDataSourceResultAsync&lt;OrderViewModel, Order&gt;(request, ModelState, x =&gt; new Order()
{
OrderID = x.OrderID
});
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult(this IEnumerable enumerable, DataSourceRequest request, ModelStateDictionary modelState)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult(request, ModelState);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult(this IEnumerable enumerable, DataSourceRequest request)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult(request);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2, TResult>(this IEnumerable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, Func<TModel, TResult> selector)
Parameters:queryableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2, TResult>(this IEnumerable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:queryableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2, TResult>(this IEnumerable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Func<TModel, TResult> selector)
Parameters:queryableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2, TResult>(this IEnumerable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:queryableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2>(this IEnumerable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState)
Parameters:queryableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2>(this IQueryable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState)
Parameters:enumerableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2>(this IQueryable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector)
Parameters:enumerableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, T1, T2>(this IQueryable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector)
Parameters:enumerableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo);
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, Employee&gt;(request, x =&gt; new Employee()
{
EmployeeId = x.EmployeeId
});
return Json(result);
}

Applies 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 TreeDataSourceResult ToTreeDataSourceResult<TModel, TResult>(this IQueryable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

TreeDataSourceResult

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

Example:
C#
public JsonResult Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = GetEmployees(id).ToTreeDataSourceResult&lt;EmployeeViewModel, Employee&gt;(request, x =&gt; new Employee()
{
EmployeeId = x.EmployeeId
});
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync(this IEnumerable enumerable, DataSourceRequest request, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync(request, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync(this IEnumerable enumerable, DataSourceRequest request, ModelStateDictionary modelState, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync(request, ModelState, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync(this IEnumerable enumerable, DataSourceRequest request, ModelStateDictionary modelState)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync(request, ModelState);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync(this IEnumerable enumerable, DataSourceRequest request)
Parameters:enumerableIEnumerable

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync(request);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?, Employee&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId });
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState, s =&gt; new Employee() { EmployeeId = s.EmployeeId }, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector, ModelStateDictionary modelState)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren, ModelState);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, Expression<Func<TModel, bool>> rootSelector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

rootSelectorExpression<Func<TModel, bool>>

The lambda which configures the root selector.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, z =&gt; z.hasChildren);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState, token);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector, ModelStateDictionary modelState)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

modelStateModelStateDictionary

An instance of ModelStateDictionary.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo, ModelState);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, T1, T2>(this IQueryable<TModel> queryable, DataSourceRequest request, Expression<Func<TModel, T1>> idSelector, Expression<Func<TModel, T2>> parentIDSelector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

idSelectorExpression<Func<TModel, T1>>

The lambda which configures the selector of the ID field.

parentIDSelectorExpression<Func<TModel, T2>>

The lambda which configures the parent selector.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, int, int?&gt;(request, x =&gt; x.EmployeeId, y =&gt; y.ReportsTo);
return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, Employee&gt;(request, x =&gt; new Employee()
{
EmployeeId = x.EmployeeId
}, token);

return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, TResult>(this IEnumerable<TModel> enumerable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:enumerableIEnumerable<TModel>

An instance of IEnumerable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, Employee&gt;(request, x =&gt; new Employee()
{
EmployeeId = x.EmployeeId
});

return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Func<TModel, TResult> selector, CancellationToken cancellationToken)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

cancellationTokenCancellationToken

An instance of CancellationToken.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
CancellationTokenSource source = new CancellationTokenSource(2000);
CancellationToken token = source.Token;

var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, Employee&gt;(request, x =&gt; new Employee()
{
EmployeeId = x.EmployeeId
}, token);

return Json(result);
}

Applies 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<TreeDataSourceResult> ToTreeDataSourceResultAsync<TModel, TResult>(this IQueryable<TModel> queryable, DataSourceRequest request, Func<TModel, TResult> selector)
Parameters:queryableIQueryable<TModel>

An instance of IQueryable.

requestDataSourceRequest

An instance of DataSourceRequest.

selectorFunc<TModel, TResult>

A projection function to apply to each element.

Returns:

Task<TreeDataSourceResult>

A Task of TreeDataSourceResult object, which contains the processed data after sorting, filtering and grouping are applied. It can be called with the "await" keyword for asynchronous operation.

Example:
C#
public async Task&lt;JsonResult&gt; Employees_Read([DataSourceRequest] DataSourceRequest request, int? id)
{
var result = await GetEmployees(id).ToTreeDataSourceResultAsync&lt;EmployeeViewModel, Employee&gt;(request, x =&gt; new Employee()
{
EmployeeId = x.EmployeeId
});

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
IQueryable&lt;OrderViewModel&gt; additionalOrders = GetAdditionalOrders();
var total = orders.Count();

orders.Union(additionalOrders);

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
orders.Where(x =&gt; x.Freight &gt; 100);
var total = orders.Count();

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}

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.

Example:
C#
public IActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
{
IQueryable&lt;OrderViewModel&gt; orders = GetOrders();
orders.Where(request.Filters);
var total = orders.Count();

var result = new DataSourceResult()
{
Data = orders,
Total = total
};

return Json(result);
}