/// <summary> /// Filters a sequence of values to return descendants of all given items. /// </summary> /// <param name="collection">sequence to filter. </param> /// <param name="items">sequence of parent items to find it's descendants. </param> /// <param name="depth">Level of inheritance to filter descendants. /// 1 returns only direct children, 2 - children of children etc. /// -1 to return all descendants down to deepest leaves. /// -1 by default. </param> /// <param name="includeSelf">Whether or not to include given parent items itself in list. false by default. </param> /// <typeparam name="TResult">Type of sequence containing ancestors elements. Should implement <see cref="IHasTreeEntry"/>. </typeparam> /// <typeparam name="TFilter">Type of referenced items to use in filter. Should implement <see cref="IHasTreeEntry"/>. </typeparam> /// <returns>Sequence of descendants of given items. </returns> public static IQueryable <TResult> DescendantsOfAny <TResult, TFilter>( this IQueryable <TResult> collection, IEnumerable <TFilter> items, int depth = -1, bool includeSelf = false) where TResult : IHasTreeEntry where TFilter : IHasTreeEntry { return(collection.Where(i => i.TreeEntry, NestedIntervalsSpec.DescendantsOfAll(items, depth, includeSelf))); }
/// <summary> /// Filters a sequence of values to return descendants of all given items. /// </summary> /// <param name="collection">sequence to filter. </param> /// <param name="navigateExpr">Property expression returning path to IHasTreeEntry item. </param> /// <param name="items">sequence of parent items to find it's descendants. </param> /// <param name="depth">Level of inheritance to filter descendants. /// 1 returns only direct children, 2 - children of children etc. /// -1 to return all descendants down to deepest leaves. /// -1 by default. </param> /// <param name="includeSelf">Whether or not to include given parent items itself in list. false by default. </param> /// <typeparam name="TResult">Type of sequence containing descendants elements. Should implement <see cref="IHasTreeEntry"/>. </typeparam> /// <typeparam name="TFilter">Type of referenced items to use in filter. Should implement <see cref="IHasTreeEntry"/>. </typeparam> /// <returns>Sequence of descendants of given items. </returns> public static IQueryable <TResult> DescendantsOfAny <TResult, TFilter>( this IQueryable <TResult> collection, Expression <Func <TResult, IHasTreeEntry> > navigateExpr, IEnumerable <TFilter> items, int depth = -1, bool includeSelf = false) where TFilter : IHasTreeEntry { return(collection.Where(navigateExpr.Navigate(i => i.TreeEntry), NestedIntervalsSpec.DescendantsOfAll(items, depth, includeSelf))); }