Search Results for

    Show / Hide Table of Contents

    Class LinqExtensions

    Inheritance
    object
    LinqExtensions
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: LemonEdge.Utils
    Assembly: LemonEdge.Utils.dll
    Syntax
    public static class LinqExtensions

    Methods

    AsArray<T>(T)

    Converts a single item of T into a one element array of T.

    Declaration
    public static T[] AsArray<T>(this T item)
    Parameters
    Type Name Description
    T item
    Returns
    Type Description
    T[]
    Type Parameters
    Name Description
    T

    Flatten<T>(IEnumerable<T>, Func<T, IEnumerable<T>, IEnumerable<T>>)

    This method extends the LINQ methods to flatten a collection of items that have a property of children of the same type.

    Declaration
    public static IEnumerable<T> Flatten<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>, IEnumerable<T>> childPropertySelector)
    Parameters
    Type Name Description
    IEnumerable<T> source

    Source collection.

    Func<T, IEnumerable<T>, IEnumerable<T>> childPropertySelector

    Child property selector delegate of each item. IEnumerable'T' childPropertySelector (T itemBeingFlattened, IEnumerable'T' objectsBeingFlattened)

    Returns
    Type Description
    IEnumerable<T>

    Returns a one level list of elements of type T.

    Type Parameters
    Name Description
    T

    Item type.

    Flatten<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)

    This method extends the LINQ methods to flatten a collection of items that have a property of children of the same type.

    Declaration
    public static IEnumerable<T> Flatten<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> childPropertySelector)
    Parameters
    Type Name Description
    IEnumerable<T> source

    Source collection.

    Func<T, IEnumerable<T>> childPropertySelector

    Child property selector delegate of each item. IEnumerable'T' childPropertySelector(T itemBeingFlattened)

    Returns
    Type Description
    IEnumerable<T>

    Returns a one level list of elements of type T.

    Type Parameters
    Name Description
    T

    Item type.

    Max<T, Y>(IEnumerable<T>, Func<T, Y>, Y)

    Declaration
    public static Y Max<T, Y>(this IEnumerable<T> items, Func<T, Y> predicate, Y def) where Y : struct, IComparable<Y>
    Parameters
    Type Name Description
    IEnumerable<T> items
    Func<T, Y> predicate
    Y def
    Returns
    Type Description
    Y
    Type Parameters
    Name Description
    T
    Y

    Min<T, Y>(IEnumerable<T>, Func<T, Y>, Y)

    Declaration
    public static Y Min<T, Y>(this IEnumerable<T> items, Func<T, Y> predicate, Y def) where Y : struct, IComparable<Y>
    Parameters
    Type Name Description
    IEnumerable<T> items
    Func<T, Y> predicate
    Y def
    Returns
    Type Description
    Y
    Type Parameters
    Name Description
    T
    Y

    Sum<T>(IEnumerable<T>, Func<T, decimal>, decimal)

    Declaration
    public static decimal Sum<T>(this IEnumerable<T> items, Func<T, decimal> predicate, decimal def)
    Parameters
    Type Name Description
    IEnumerable<T> items
    Func<T, decimal> predicate
    decimal def
    Returns
    Type Description
    decimal
    Type Parameters
    Name Description
    T

    ToArrayOfOne<T>(T)

    Turns this T item into:

    new T[]{item};
    Declaration
    public static T[] ToArrayOfOne<T>(this T item)
    Parameters
    Type Name Description
    T item
    Returns
    Type Description
    T[]
    Type Parameters
    Name Description
    T

    ToListOfOne<T>(T)

    Turns this T item into:

    new List{T}{item};
    Declaration
    public static IList<T> ToListOfOne<T>(this T item)
    Parameters
    Type Name Description
    T item
    Returns
    Type Description
    IList<T>
    Type Parameters
    Name Description
    T

    WithIndex<T>(IEnumerable<T>)

    Generates an enumeration with the corresponding index value.

    Declaration
    public static IEnumerable<(T item, int index)> WithIndex<T>(this IEnumerable<T> source)
    Parameters
    Type Name Description
    IEnumerable<T> source

    The source enumeration.

    Returns
    Type Description
    IEnumerable<(T item, int index)>

    An enumeration with the corresponding index value.

    Type Parameters
    Name Description
    T

    The generic type.

    In this article
    Back to top © LemonEdge Technologies. All rights reserved.