/// <summary> /// LINQ's OrderBy operator for generic EnumerableRowCollection. /// </summary> public static OrderedEnumerableRowCollection <TRow> OrderBy <TRow, TKey>(this TypedTableBase <TRow> source, Func <TRow, TKey> keySelector) where TRow : DataRow { DataSetUtil.CheckArgumentNull(nameof(source), "source"); EnumerableRowCollection <TRow> erc = new EnumerableRowCollection <TRow>(source); return(erc.OrderBy(keySelector)); }
/// <summary> /// Executes a Select (Projection) on EnumerableDataTable. If the selector returns a different /// type than the type of rows, then AsLinqDataView is disabled, and the returning EnumerableDataTable /// represents an enumerable over the LINQ Query. /// </summary> public static EnumerableRowCollection <S> Select <TRow, S>(this TypedTableBase <TRow> source, Func <TRow, S> selector) where TRow : DataRow { DataSetUtil.CheckArgumentNull(nameof(source), "source"); EnumerableRowCollection <TRow> erc = new EnumerableRowCollection <TRow>(source); return(erc.Select(selector)); }
/// <summary> /// LINQ's Where operator for generic EnumerableRowCollection. /// </summary> public static EnumerableRowCollection <TRow> Where <TRow>(this TypedTableBase <TRow> source, Func <TRow, bool> predicate) where TRow : DataRow { DataSetUtil.CheckArgumentNull(nameof(source), "source"); EnumerableRowCollection <TRow> erc = new EnumerableRowCollection <TRow>(source); return(erc.Where(predicate)); }
/// <summary> /// LINQ's OrderByDescending operator for generic EnumerableRowCollection. /// </summary> public static OrderedEnumerableRowCollection <TRow> OrderByDescending <TRow, TKey>( this TypedTableBase <TRow> source, Func <TRow, TKey> keySelector, IComparer <TKey> comparer) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, nameof(source)); EnumerableRowCollection <TRow> erc = new EnumerableRowCollection <TRow>(source); return(erc.OrderByDescending(keySelector, comparer)); }
public static TRow ElementAtOrDefault <TRow>(this TypedTableBase <TRow> source, int index) where TRow : DataRow { if ((index >= 0) && (index < source.Rows.Count)) { return((TRow)source.Rows[index]); } else { return(default(TRow)); } }
/// <summary> /// This method returns a IEnumerable of TRow. /// </summary> /// <param name="source">The source DataTable to make enumerable.</param> /// <returns>IEnumerable of datarows.</returns> public static EnumerableRowCollection <TRow> AsEnumerable <TRow>(this TypedTableBase <TRow> source) where TRow : DataRow { DataSetUtil.CheckArgumentNull(nameof(source), "source"); return(new EnumerableRowCollection <TRow>(source as DataTable)); }
public static EnumerableRowCollection <TRow> Where <TRow> (this TypedTableBase <TRow> source, Func <TRow, bool> predicate) where TRow : DataRow { return(new EnumerableRowCollection <TRow> (Enumerable.Where <TRow> (source, predicate))); }
public static EnumerableRowCollection <S> Select <TRow, S> (this TypedTableBase <TRow> source, Func <TRow, S> selector) where TRow : DataRow { return(new EnumerableRowCollection <S> (Enumerable.Select <TRow, S> (source, selector))); }
public static OrderedEnumerableRowCollection <TRow> OrderByDescending <TRow, TKey> (this TypedTableBase <TRow> source, Func <TRow, TKey> keySelector, IComparer <TKey> comparer) where TRow : DataRow { return(OrderedEnumerableRowCollection <TRow> .Create <TRow, TKey> (source, keySelector, comparer, true)); }
public static OrderedEnumerableRowCollection <TRow> OrderByDescending <TRow, TKey> (this TypedTableBase <TRow> source, Func <TRow, TKey> keySelector) where TRow : DataRow { return(OrderByDescending <TRow, TKey> (source, keySelector, Comparer <TKey> .Default)); }
public static EnumerableRowCollection <TRow> AsEnumerable <TRow> (this TypedTableBase <TRow> source) where TRow : DataRow { return(new EnumerableRowCollection <TRow> (source)); }