Class LINQExtensions
- Namespace
- CapyKit.Extensions
- Assembly
- CapyKit.dll
Provides static extension methods for performing common LINQ operations on IEnumerable<T> and IQueryable<T> collections.
public static class LINQExtensions
- Inheritance
-
LINQExtensions
- Inherited Members
Methods
Distinct<T, U>(IEnumerable<T>, Func<T, U>)
Enumerates distinct items in this collection as defined by the key property.
public static IEnumerable<T> Distinct<T, U>(this IEnumerable<T> items, Func<T, U> property)
Parameters
itemsIEnumerable<T>The items to act on.
propertyFunc<T, U>The property.
Returns
- IEnumerable<T>
An enumerator that allows foreach to be used to process distinct items in this collection.
Type Parameters
TGeneric type parameter of the parent object.
UGeneric type parameter property value.
Filter<T>(IEnumerable<T>, Func<T, bool>)
Filters out items matching a predicate from the collection.
public static IEnumerable<T> Filter<T>(this IEnumerable<T> source, Func<T, bool> predicate)
Parameters
sourceIEnumerable<T>The source to act on.
predicateFunc<T, bool>The predicate.
Returns
- IEnumerable<T>
An enumerator that allows foreach to be used to process remove in this collection.
Type Parameters
TGeneric type parameter.
Filter<T>(IQueryable<T>, Expression<Func<T, bool>>)
Filters out items matching a predicate from the collection.
public static IQueryable<T> Filter<T>(this IQueryable<T> source, Expression<Func<T, bool>> predicate)
Parameters
sourceIQueryable<T>The source to act on.
predicateExpression<Func<T, bool>>The predicate.
Returns
- IQueryable<T>
An enumerator that allows foreach to be used to process remove in this collection.
Type Parameters
TGeneric type parameter.
LeftOuterJoin<T, U, TKey, R>(IEnumerable<T>, IEnumerable<U>, Func<T, TKey>, Func<U, TKey>, Func<T, IEnumerable<U>, R>, Func<T, U>)
An IEnumable<T> extension method that left outer join.
public static IEnumerable<R> LeftOuterJoin<T, U, TKey, R>(this IEnumerable<T> source, IEnumerable<U> inner, Func<T, TKey> outerSelector, Func<U, TKey> innerSelector, Func<T, IEnumerable<U>, R> resultSelector, Func<T, U> defaultGenerator = null)
Parameters
sourceIEnumerable<T>The source to act on.
innerIEnumerable<U>The inner.
outerSelectorFunc<T, TKey>The outer selector.
innerSelectorFunc<U, TKey>The inner selector.
resultSelectorFunc<T, IEnumerable<U>, R>The result selector.
defaultGeneratorFunc<T, U>(Optional) The default generator.
Returns
- IEnumerable<R>
An enumerator that allows foreach to be used to process left outter join in this collection.
Type Parameters
TGeneric type parameter.
UGeneric type parameter.
TKeyType of the key.
RType of the r.
LeftOuterJoin<T, U, TKey, R>(IQueryable<T>, IQueryable<U>, Expression<Func<T, TKey>>, Expression<Func<U, TKey>>, Func<T, IEnumerable<U>, R>, Func<T, U>)
An IQueryable<T> extension method that left outer join.
public static IQueryable<R> LeftOuterJoin<T, U, TKey, R>(this IQueryable<T> source, IQueryable<U> inner, Expression<Func<T, TKey>> outerSelector, Expression<Func<U, TKey>> innerSelector, Func<T, IEnumerable<U>, R> resultSelector, Func<T, U> defaultGenerator = null)
Parameters
sourceIQueryable<T>The source to act on.
innerIQueryable<U>The inner.
outerSelectorExpression<Func<T, TKey>>The outer selector.
innerSelectorExpression<Func<U, TKey>>The inner selector.
resultSelectorFunc<T, IEnumerable<U>, R>The result selector.
defaultGeneratorFunc<T, U>(Optional) The default generator.
Returns
- IQueryable<R>
An IQueryable<R>
Type Parameters
TGeneric type parameter.
UGeneric type parameter.
TKeyType of the key.
RType of the r.
PageCount<T>(IEnumerable<T>, int)
The number of pages of pageSize size in the given collection.
public static int PageCount<T>(this IEnumerable<T> source, int pageSize)
Parameters
sourceIEnumerable<T>The source to act on.
pageSizeintSize of the page.
Returns
- int
An int.
Type Parameters
TGeneric type parameter.
Exceptions
- ArgumentOutOfRangeException
Thrown when
pageSizeis less than1.
PageCount<T>(IQueryable<T>, int)
The number of pages of pageSize size in the given collection.
public static int PageCount<T>(this IQueryable<T> source, int pageSize)
Parameters
sourceIQueryable<T>The source to act on.
pageSizeintSize of the page.
Returns
- int
An int.
Type Parameters
TGeneric type parameter.
Exceptions
- ArgumentOutOfRangeException
Thrown when
pageSizeis less than1.
Page<T>(IEnumerable<T>, int, int)
Get a page of items from a collection, skipping pageNumber pages of
pageSize items per page.
public static IEnumerable<T> Page<T>(this IEnumerable<T> source, int pageNumber, int pageSize)
Parameters
sourceIEnumerable<T>The source to act on.
pageNumberintThe page number to retrieve.
pageSizeintNumber of items per page.
Returns
- IEnumerable<T>
An enumerator that allows foreach to be used to process page in this collection.
Type Parameters
TGeneric type parameter.
Remarks
This method uses natural numbering starting at page 1.
Exceptions
- ArgumentOutOfRangeException
Thrown when
pageNumberis less than1or ifpageSizeis less than1.
Page<T>(IQueryable<T>, int, int)
Get a page of items from a collection, skipping pageNumber pages of
pageSize items per page.
public static IQueryable<T> Page<T>(this IQueryable<T> source, int pageNumber, int pageSize)
Parameters
sourceIQueryable<T>The source to act on.
pageNumberintThe page number to retrieve.
pageSizeint.
Returns
- IQueryable<T>
An enumerator that allows foreach to be used to process page in this collection.
Type Parameters
TGeneric type parameter.
Remarks
This method uses natural numbering starting at page 1.
Exceptions
- ArgumentOutOfRangeException
Thrown when
pageNumberis less than1or ifpageSizeis less than1.