1. 程式人生 > >名稱空間System.Linq下的類Queryable

名稱空間System.Linq下的類Queryable

using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace System.Linq
{
    public static class Queryable
    {

        //***************************************************Aggregate*****************************************************
        public static TResult Aggregate<TSource, TAccumulate, TResult>(this IQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> func, Expression<Func<TAccumulate, TResult>> selector);
        public static TSource Aggregate<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, TSource, TSource>> func);
        public static TAccumulate Aggregate<TSource, TAccumulate>(this IQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> func);

        //*****************************************************All、 Any******************************************************
        public static bool All<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
        public static bool Any<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
        public static bool Any<TSource>(this IQueryable<TSource> source);

        //******************************************************AsQueryable*****************************************************
        public static IQueryable<TElement> AsQueryable<TElement>(this IEnumerable<TElement> source);
        public static IQueryable AsQueryable(this IEnumerable source);

        //******************************************************Average***********************************************************
        public static double Average(this IQueryable<double> source);
        public static double Average(this IQueryable<int> source);
        public static double? Average(this IQueryable<int?> source);
        public static double Average(this IQueryable<long> source);
        public static double? Average(this IQueryable<long?> source);
        public static float Average(this IQueryable<float> source);
        public static float? Average(this IQueryable<float?> source);
        public static double? Average(this IQueryable<double?> source);
        public static decimal Average(this IQueryable<decimal> source);
        public static decimal? Average(this IQueryable<decimal?> source);
        public static double Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int>> selector);
        public static double? Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int?>> selector);
        public static float Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float>> selector);
        public static float? Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float?>> selector);
        public static double Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long>> selector);
        public static double? Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long?>> selector);
        public static double Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double>> selector);
        public static double? Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double?>> selector);
        public static decimal Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal>> selector);
        public static decimal? Average<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector);

        //*****************************************************Cast******************************************************
        public static IQueryable<TResult> Cast<TResult>(this IQueryable source);

        //****************************************************Concat**********************************************************
        public static IQueryable<TSource> Concat<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2);

        //***************************************************Contains**********************************************************
        public static bool Contains<TSource>(this IQueryable<TSource> source, TSource item, IEqualityComparer<TSource> comparer);
        public static bool Contains<TSource>(this IQueryable<TSource> source, TSource item);

        //*****************************************************Count**************************************************************
        public static int Count<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
        public static int Count<TSource>(this IQueryable<TSource> source);

        //*****************************************************DefaultIfEmpty************************************************
        public static IQueryable<TSource> DefaultIfEmpty<TSource>(this IQueryable<TSource> source, TSource defaultValue);
        public static IQueryable<TSource> DefaultIfEmpty<TSource>(this IQueryable<TSource> source);

        //*****************************************************Distinct************************************************************
        public static IQueryable<TSource> Distinct<TSource>(this IQueryable<TSource> source, IEqualityComparer<TSource> comparer);
        public static IQueryable<TSource> Distinct<TSource>(this IQueryable<TSource> source);

        //***************************************************ElementAt********************************************************
        public static TSource ElementAt<TSource>(this IQueryable<TSource> source, int index);

        //****************************************************ElementAtOrDefault*********************************************
        public static TSource ElementAtOrDefault<TSource>(this IQueryable<TSource> source, int index);

        //********************************************************Except*********************************************************
        public static IQueryable<TSource> Except<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2);
        public static IQueryable<TSource> Except<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2, IEqualityComparer<TSource> comparer);

        //********************************************************First**************************************************************
        public static TSource First<TSource>(this IQueryable<TSource> source);
        public static TSource First<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);

        //********************************************************FirstOrDefault***************************************************
        public static TSource FirstOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
        public static TSource FirstOrDefault<TSource>(this IQueryable<TSource> source);

        //*********************************************************GroupBy***************************************************
        public static IQueryable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<TKey, IEnumerable<TElement>, TResult>> resultSelector);
        public static IQueryable<TResult> GroupBy<TSource, TKey, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TKey, IEnumerable<TSource>, TResult>> resultSelector);
        public static IQueryable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector);
        public static IQueryable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<TKey, IEnumerable<TElement>, TResult>> resultSelector, IEqualityComparer<TKey> comparer);
        public static IQueryable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector);
        public static IQueryable<TResult> GroupBy<TSource, TKey, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TKey, IEnumerable<TSource>, TResult>> resultSelector, IEqualityComparer<TKey> comparer);
        public static IQueryable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer);
        public static IQueryable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer);
        //*****************************************************GruopJoin**************************************************
        public static IQueryable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IQueryable<TOuter> outer, IEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, IEnumerable<TInner>, TResult>> resultSelector, IEqualityComparer<TKey> comparer);
        public static IQueryable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IQueryable<TOuter> outer, IEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, IEnumerable<TInner>, TResult>> resultSelector);

        //*****************************************************Intersect***********************************************************
        public static IQueryable<TSource> Intersect<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2, IEqualityComparer<TSource> comparer);
        public static IQueryable<TSource> Intersect<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2);
        //*****************************************************Join*************************************************************
        public static IQueryable<TResult> Join<TOuter, TInner, TKey, TResult>(this IQueryable<TOuter> outer, IEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, TInner, TResult>> resultSelector, IEqualityComparer<TKey> comparer);
        public static IQueryable<TResult> Join<TOuter, TInner, TKey, TResult>(this IQueryable<TOuter> outer, IEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, TInner, TResult>> resultSelector);

        //*******************************************************Last**************************************************************
        public static TSource Last<TSource>(this IQueryable<TSource> source);
        public static TSource Last<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);

        //******************************************************LastOrDefault****************************************************
        public static TSource LastOrDefault<TSource>(this IQueryable<TSource> source);
        public static TSource LastOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);

        //*******************************************************LongCount********************************************************
        public static long LongCount<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
        public static long LongCount<TSource>(this IQueryable<TSource> source);

        //*********************************************************Max***************************************************************
        public static TResult Max<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector);
        public static TSource Max<TSource>(this IQueryable<TSource> source);

        //*********************************************************Min***************************************************************
        public static TResult Min<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector);
        public static TSource Min<TSource>(this IQueryable<TSource> source);

        //*********************************************************OfType***********************************************************
        public static IQueryable<TResult> OfType<TResult>(this IQueryable source);

        //********************************************************OrderBy*****************************************************
        public static IOrderedQueryable<TSource> OrderBy<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer);
        public static IOrderedQueryable<TSource> OrderBy<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector);

        //************************************************************OrderByDescending***************************************
        public static IOrderedQueryable<TSource> OrderByDescending<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector);
        public static IOrderedQueryable<TSource> OrderByDescending<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer);

        //*******************************************************************Reverse**************************************************
        public static IQueryable<TSource> Reverse<TSource>(this IQueryable<TSource> source);

        //*******************************************************************Select*****************************************************
        public static IQueryable<TResult> Select<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, int, TResult>> selector);
        public static IQueryable<TResult> Select<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector);

        //************************************************************SelectMany*************************************************
        public static IQueryable<TResult> SelectMany<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector);
        public static IQueryable<TResult> SelectMany<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector);
        public static IQueryable<TResult> SelectMany<TSource, TCollection, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, int, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector);
        public static IQueryable<TResult> SelectMany<TSource, TCollection, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector);

        //*********************************************************SequenceEqual*********************************************
        public static bool SequenceEqual<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2, IEqualityComparer<TSource> comparer);
        public static bool SequenceEqual<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2);

        //**********************************************************Single***********************************************************
        public static TSource Single<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
        public static TSource Single<TSource>(this IQueryable<TSource> source);

        //****************************************************SingleOrDefault****************************************************
        public static TSource SingleOrDefault<TSource>(this IQueryable<TSource> source);
        public static TSource SingleOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);

        //***********************************************************Skip*******************************************************
        public static IQueryable<TSource> Skip<TSource>(this IQueryable<TSource> source, int count);

        //*****************************************************SkipWhile*************************************************************
        public static IQueryable<TSource> SkipWhile<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
        public static IQueryable<TSource> SkipWhile<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int, bool>> predicate);

        //****************************************************************Sum***************************************************
        public static decimal Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal>> selector);
        public static decimal? Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector);
        public static double? Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double?>> selector);
        public static double Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double>> selector);
        public static int? Sum(this IQueryable<int?> source);
        public static float Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float>> selector);
        public static int Sum(this IQueryable<int> source);
        public static long Sum(this IQueryable<long> source);
        public static long? Sum(this IQueryable<long?> source);
        public static float Sum(this IQueryable<float> source);
        public static float? Sum(this IQueryable<float?> source);
        public static double Sum(this IQueryable<double> source);
        public static double? Sum(this IQueryable<double?> source);
        public static float? Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float?>> selector);
        public static decimal Sum(this IQueryable<decimal> source);
        public static decimal? Sum(this IQueryable<decimal?> source);
        public static int Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int>> selector);
        public static long? Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long?>> selector);
        public static long Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long>> selector);
        public static int? Sum<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int?>> selector);

        //***********************************************************Take**************************************************
        public static IQueryable<TSource> Take<TSource>(this IQueryable<TSource> source, int count);

        //*****************************************************TakeWhile****************************************************
        public static IQueryable<TSource> TakeWhile<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
        public static IQueryable<TSource> TakeWhile<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int, bool>> predicate);

        //**************************************************ThenBy*********************************************************
        public static IOrderedQueryable<TSource> ThenBy<TSource, TKey>(this IOrderedQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer);
        public static IOrderedQueryable<TSource> ThenBy<TSource, TKey>(this IOrderedQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector);

        //***************************************************ThenByDescending****************************************************
        public static IOrderedQueryable<TSource> ThenByDescending<TSource, TKey>(this IOrderedQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector);
        public static IOrderedQueryable<TSource> ThenByDescending<TSource, TKey>(this IOrderedQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer);

        //*******************************************************Union******************************************************************
        public static IQueryable<TSource> Union<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2, IEqualityComparer<TSource> comparer);
        public static IQueryable<TSource> Union<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2);

        //*****************************************************Where**********************************************************************
        public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int, bool>> predicate);
        public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);

        //************************************************Zip*************************************************************************************
        public static IQueryable<TResult> Zip<TFirst, TSecond, TResult>(this IQueryable<TFirst> source1, IEnumerable<TSecond> source2, Expression<Func<TFirst, TSecond, TResult>> resultSelector);
    }
}