[]
        
(Showing Draft Content)

GrapeCity.Enterprise.Data.Expressions.Tools.EnumerableExtensions.Flatten

Flatten Method

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>> childSelector)
Parameters
Type Name Description
IEnumerable<T> source

Source collection.

Func<T, IEnumerable<T>> childSelector

function that returns a collection of children for each item

Returns
Type Description
IEnumerable<T>

Returns a one level list of elements of type T.

Type Parameters
Name Description
T

Item type

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

This method extends the LINQ methods to obtain a single-level collection of descendants(is a collections) of an object of type T

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

The object of type T.

Func<T, IEnumerable<T>> childSelector

function that returns a collection of children

Returns
Type Description
IEnumerable<T>

Returns a one level list of elements of type T.

Type Parameters
Name Description
T

Item type.

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

This method extends the LINQ methods to obtain a single-level collection of descendants(is an object) of an object of type T

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

The object of type T.

Func<T, T> childSelector

function that returns of children object of type T.

Returns
Type Description
IEnumerable<T>

Returns a one level list of elements of type T.

Type Parameters
Name Description
T

Item type.