November Happy Hour will be moved to Thursday December 5th.

Class CollectionExtensions

Implements sorting extesions for dynamic column names and sort order defined by the SortColumn struct and ranging extensions for using the ItemRange class.

Inheritance
System.Object
CollectionExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Shell.Services.Rest
Assembly: EPiServer.Shell.dll
Version: 10.10.4
Syntax
public static class CollectionExtensions

Methods

ApplyRange<T>(IEnumerable<T>, ItemRange)

Applies the specified range (start, end) and returns the items in the range together with the actual range (start, end, total).

Declaration
public static RangedItems<T> ApplyRange<T>(this IEnumerable<T> items, ItemRange requestedRange)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> items

The full item collection to get the range from.

ItemRange requestedRange

The requested range with start and/or end set. Null or not defined (neither start nor end set) to return the full range.

Returns
Type Description
RangedItems<T>

A RangedItems<T> instance containing the resulting range of items as well as a new ItemRange instance describing the actual range (including total).

Type Parameters
Name Description
T

The type of items to apply range to.

ApplyRange<T>(IEnumerable<T>, ItemRange, Nullable<Int32>)

Applies the specified range (start, end) and returns the items in the range together with the actual range (start, end, total), using a supplied total count which means that items don't have to be enumerated to get the count.

Declaration
public static RangedItems<T> ApplyRange<T>(this IEnumerable<T> items, ItemRange requestedRange, int? totalItemCount)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> items

The full item collection to get the range from.

ItemRange requestedRange

The requested range with start and/or end set. Null or not defined (neither start nor end set) to return the full range.

System.Nullable<System.Int32> totalItemCount

The total item count, or null if it should be reported as unknown. To get the actual total count by enumerating items, use the overload without the totalItemCount parameter.

Returns
Type Description
RangedItems<T>

A RangedItems<T> instance containing the resulting range of items as well as a new ItemRange instance describing the actual range (including total).

Type Parameters
Name Description
T

The type of items to apply range to.

ApplyRange<T>(IQueryable<T>, ItemRange)

Applies the specified range (start, end) and returns the items in the range together with the actual range (start, end, total).

Declaration
public static RangedItems<T> ApplyRange<T>(this IQueryable<T> items, ItemRange requestedRange)
Parameters
Type Name Description
System.Linq.IQueryable<T> items

The full item collection to get the range from.

ItemRange requestedRange

The requested range with start and/or end set. Null or not defined (neither start nor end set) to return the full range.

Returns
Type Description
RangedItems<T>

A RangedItems<T> instance containing the resulting range of items as well as a new ItemRange instance describing the actual range (including total).

Type Parameters
Name Description
T

The type of items to apply range to.

ApplyRange<T>(IQueryable<T>, ItemRange, Nullable<Int32>)

Applies the specified range (start, end) and returns the items in the range together with the actual range (start, end, total), using a supplied total count which means that items don't have to be enumerated to get the count.

Declaration
public static RangedItems<T> ApplyRange<T>(this IQueryable<T> items, ItemRange requestedRange, int? totalItemCount)
Parameters
Type Name Description
System.Linq.IQueryable<T> items

The full item collection to get the range from.

ItemRange requestedRange

The requested range with start and/or end set. Null or not defined (neither start nor end set) to return the full range.

System.Nullable<System.Int32> totalItemCount

The total item count, or null if it should be reported as unknown. To get the actual total count by enumerating items, use the overload without the totalItemCount parameter.

Returns
Type Description
RangedItems<T>

A RangedItems<T> instance containing the resulting range of items as well as a new ItemRange instance describing the actual range (including total).

Type Parameters
Name Description
T

The type of items to apply range to.

OrderBy<TSource>(IQueryable<TSource>, SortColumn)

Orders the System.Linq.IQueryable<> source by the directives in the sort parameter.

Declaration
public static IQueryable<TSource> OrderBy<TSource>(this IQueryable<TSource> source, SortColumn sortColumn)
Parameters
Type Name Description
System.Linq.IQueryable<TSource> source

The source containing the items to sort.

SortColumn sortColumn

The sort column definition.

Returns
Type Description
System.Linq.IQueryable<TSource>

The source with the sort expression appended

Type Parameters
Name Description
TSource

The type of the source.

Exceptions
Type Condition
System.ArgumentNullException

if source is null

OrderBy<TSource>(IQueryable<TSource>, IEnumerable<SortColumn>)

Orders the System.Linq.IQueryable<> using a collection of SortColumns.

Declaration
public static IQueryable<TSource> OrderBy<TSource>(this IQueryable<TSource> source, IEnumerable<SortColumn> sortColumns)
Parameters
Type Name Description
System.Linq.IQueryable<TSource> source

The source.

System.Collections.Generic.IEnumerable<SortColumn> sortColumns

The sort columns.

Returns
Type Description
System.Linq.IQueryable<TSource>

The source with the sort expression(s) appended

Type Parameters
Name Description
TSource
Exceptions
Type Condition
System.ArgumentNullException

if source or sortColumns is null