public void OrderByDescending_AddSortExpressionValidation()
        {
            var(table, one, two, three) = InstantiateTable();

            EnumerableRowCollection <DataRow> source = table.Cast <DataRow>();
            var orderedBackwards = source.OrderByDescending(row => int.Parse((string)row.ItemArray[0]));

            Assert.Equal(new DataRow[] { three, two, one }, orderedBackwards);

            DataRow four = table.Rows.Add(4);
            var     comparedBackwards = source.OrderByDescending((row => row), new TestDataRowComparer <DataRow>());

            Assert.Equal(new DataRow[] { four, three, two, one }, comparedBackwards);
        }
Exemple #2
0
        /// <summary>
        /// LINQ's OrderByDescending operator for generic EnumerableRowCollection.
        /// </summary>
        public static OrderedEnumerableRowCollection <TRow> OrderByDescending <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.OrderByDescending(keySelector));
        }