| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852 |
- //
- // Queryable.cs
- //
- // Authors:
- // Marek Safar ([email protected])
- // Alejandro Serrano "Serras" ([email protected])
- // Jb Evain ([email protected])
- //
- // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
- //
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using System.Reflection;
- namespace System.Linq {
- public static class Queryable {
- static MethodInfo MakeGeneric (MethodBase method, params Type [] parameters)
- {
- return ((MethodInfo) method).MakeGenericMethod (parameters);
- }
- static Expression StaticCall (MethodInfo method, params Expression [] expressions)
- {
- return Expression.Call (null, method, expressions);
- }
- static TRet Execute<TRet, TSource> (this IQueryable<TSource> source, MethodBase current)
- {
- return source.Provider.Execute<TRet> (
- StaticCall (
- MakeGeneric (current, typeof (TSource)),
- source.Expression));
- }
- public static int Count<TSource> (this IQueryable<TSource> source)
- {
- Check.Source (source);
- return source.Execute<int, TSource> (MethodBase.GetCurrentMethod ());
- }
- public static int Count<TSource> (this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
- {
- Check.SourceAndPredicate (source, predicate);
- return source.Provider.Execute<int> (
- StaticCall (
- MakeGeneric (MethodBase.GetCurrentMethod (), typeof (TSource)),
- source.Expression,
- Expression.Quote (predicate)));
- }
- public static long LongCount<TSource> (this IQueryable<TSource> source)
- {
- Check.Source (source);
- return source.Execute<long, TSource> (MethodBase.GetCurrentMethod ());
- }
- public static long LongCount<TSource> (this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
- {
- Check.SourceAndPredicate (source, predicate);
- return source.Provider.Execute<long> (
- StaticCall (
- MakeGeneric (MethodBase.GetCurrentMethod (), typeof (TSource)),
- source.Expression,
- Expression.Quote (predicate)));
- }
- public static int Sum (this IQueryable<int> source)
- {
- Check.Source (source);
- return source.Provider.Execute<int> (
- StaticCall (
- (MethodInfo) MethodBase.GetCurrentMethod (),
- source.Expression));
- }
-
- public static int Sum<TSource> (this IQueryable<TSource> source, Expression<Func<TSource, int>> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static int? Sum (this IQueryable<int?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static int? Sum<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, int?> selector)
- {
- throw new NotImplementedException ();
- }
- public static long Sum (this IQueryable<long> source)
- {
- throw new NotImplementedException ();
- }
-
- public static long Sum<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, long> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static long? Sum (this IQueryable<long?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static long? Sum<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, long?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double Sum (this IQueryable<double> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double Sum<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, double> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Sum (this IQueryable<double?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Sum<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, double?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal Sum (this IQueryable<decimal> source)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal Sum<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, decimal> selector)
- {
- throw new NotImplementedException ();
- }
- public static decimal? Sum (this IQueryable<decimal?> source)
- {
- throw new NotImplementedException ();
- }
- public static decimal? Sum<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, decimal?> selector)
- {
- throw new NotImplementedException ();
- }
- public static int Min (this IQueryable<int> source)
- {
- throw new NotImplementedException ();
- }
-
- public static int? Min (this IQueryable<int?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static long Min (this IQueryable<long> source)
- {
- throw new NotImplementedException ();
- }
-
- public static long? Min (this IQueryable<long?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double Min (this IQueryable<double> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Min (this IQueryable<double?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal Min (this IQueryable<decimal> source)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal? Min (this IQueryable<decimal?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource Min<TSource> (this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static int Min<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, int> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static int? Min<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, int?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static long Min<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, long> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static long? Min<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, long?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double Min<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, double> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Min<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, double?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal Min<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, decimal> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal? Min<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, decimal?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static TResult Min<TSource, TResult> (
- this IQueryable<TSource> source,
- Func<TSource, TResult> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static int Max (this IQueryable<int> source)
- {
- throw new NotImplementedException ();
- }
-
- public static int? Max (this IQueryable<int?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static long Max (this IQueryable<long> source)
- {
- throw new NotImplementedException ();
- }
-
- public static long? Max (this IQueryable<long?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double Max (
- this IQueryable<double> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Max (
- this IQueryable<double?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal Max (
- this IQueryable<decimal> source)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal? Max (
- this IQueryable<decimal?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource Max<TSource> (
- this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static int Max<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, int> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static int? Max<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, int?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static long Max<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, long> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static long? Max<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, long?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double Max<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, double> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Max<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, double?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal Max<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, decimal> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal? Max<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, decimal?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static TResult Max<TSource, TResult> (
- this IQueryable<TSource> source,
- Func<TSource, TResult> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double Average (this IQueryable<int> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Average (this IQueryable<int?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double Average (this IQueryable<long> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Average (this IQueryable<long?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double Average (this IQueryable<double> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Average (this IQueryable<double?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal Average (this IQueryable<decimal> source)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal? Average (this IQueryable<decimal?> source)
- {
- throw new NotImplementedException ();
- }
-
- public static double Average<TSource> (this IQueryable<TSource> source,
- Func<TSource, int> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Average<TSource> (this IQueryable<TSource> source,
- Func<TSource, int?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double Average<TSource> (this IQueryable<TSource> source,
- Func<TSource, long> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Average<TSource> (this IQueryable<TSource> source,
- Func<TSource, long?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double Average<TSource> (this IQueryable<TSource> source,
- Func<TSource, double> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static double? Average<TSource> (this IQueryable<TSource> source,
- Func<TSource, double?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal Average<TSource> (this IQueryable<TSource> source,
- Func<TSource, decimal> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static decimal? Average<TSource> (this IQueryable<TSource> source,
- Func<TSource, decimal?> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource Aggregate<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, TSource, TSource> func)
- {
- throw new NotImplementedException ();
- }
-
- public static U Aggregate<TSource, U> (
- this IQueryable<TSource> source,
- U seed,
- Func<U, TSource, U> func)
- {
- throw new NotImplementedException ();
- }
- public static IEnumerable<TSource> Concat<TSource> (
- this IQueryable<TSource> first,
- IEnumerable<TSource> second)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TResult> OfType<TResult> (this IQueryable source)
- {
- throw new NotImplementedException ();
- }
- public static IEnumerable<TResult> Cast<TResult> (this IQueryable source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource First<TSource> (this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource First<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource FirstOrDefault<TSource> (this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource FirstOrDefault<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource Last<TSource> (this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource Last<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource LastOrDefault<TSource> (this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource LastOrDefault<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource Single<TSource> (this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource Single<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource SingleOrDefault<TSource> (this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource SingleOrDefault<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource ElementAt<TSource> (
- this IQueryable<TSource> source,
- int index)
- {
- throw new NotImplementedException ();
- }
-
- public static TSource ElementAtOrDefault<TSource> (
- this IQueryable<TSource> source,
- int index)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> DefaultIfEmpty<TSource> (
- this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> DefaultIfEmpty<TSource> (
- this IQueryable<TSource> source,
- TSource defaultValue)
- {
- throw new NotImplementedException ();
- }
- public static IEnumerable<TSource> Repeat<TSource> (this TSource element, int count)
- {
- throw new NotImplementedException ();
- }
-
- private static List<TSource> ContainsGroup<K, TSource>(
- Dictionary<K, List<TSource>> items, K key, IEqualityComparer<K> comparer)
- {
- throw new NotImplementedException ();
- }
-
- public static IQueryable<IGrouping<K, TSource>> GroupBy<TSource, K> (
- this IQueryable<TSource> source,
- Func<TSource, K> keySelector)
- {
- throw new NotImplementedException ();
- }
- public static IQueryable<IGrouping<K, E>> GroupBy<TSource, K, E> (
- this IQueryable<TSource> source,
- Func<TSource, K> keySelector,
- Func<TSource, E> elementSelector)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<IGrouping<K, E>> GroupBy<TSource, K, E> (
- this IQueryable<TSource> source,
- Func<TSource, K> keySelector,
- Func<TSource, E> elementSelector,
- IEqualityComparer<K> comparer)
- {
- throw new NotImplementedException ();
- }
-
- public static IOrderedQueryable<TSource> OrderBy<TSource, TKey> (
- this IQueryable<TSource> source,
- Func<TSource, TKey> keySelector)
- {
- throw new NotImplementedException ();
- }
-
- public static IOrderedQueryable<TSource> OrderBy<TSource, TKey> (
- this IQueryable<TSource> source,
- Func<TSource, TKey> keySelector,
- IComparer<TKey> comparer)
- {
- throw new NotImplementedException ();
- }
-
- public static IOrderedQueryable<TSource> OrderByDescending<TSource, TKey> (
- this IQueryable<TSource> source,
- Func<TSource, TKey> keySelector)
- {
- throw new NotImplementedException ();
- }
-
- public static IOrderedQueryable<TSource> OrderByDescending<TSource, TKey> (
- this IQueryable<TSource> source,
- Func<TSource, TKey> keySelector,
- IComparer<TKey> comparer)
- {
- throw new NotImplementedException ();
- }
- public static IOrderedQueryable<TSource> ThenBy<TSource, TKey> (
- this IOrderedQueryable<TSource> source,
- Func<TSource, TKey> keySelector)
- {
- throw new NotImplementedException ();
- }
-
- public static IOrderedQueryable<TSource> ThenBy<TSource, TKey> (
- this IOrderedQueryable<TSource> source,
- Func<TSource, TKey> keySelector,
- IComparer<TKey> comparer)
- {
- throw new NotImplementedException ();
- }
-
- public static IOrderedQueryable<TSource> ThenByDescending<TSource, TKey> (
- this IOrderedQueryable<TSource> source,
- Func<TSource, TKey> keySelector)
- {
- throw new NotImplementedException ();
- }
-
- public static IOrderedQueryable<TSource> ThenByDescending<TSource, TKey> (
- this IOrderedQueryable<TSource> source,
- Func<TSource, TKey> keySelector,
- IComparer<TKey> comparer)
- {
- throw new NotImplementedException ();
- }
- public static IQueryable<TSource> Reverse<TSource> (
- this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> Take<TSource> (
- this IQueryable<TSource> source,
- int count)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> Skip<TSource> (
- this IQueryable<TSource> source,
- int count)
- {
- throw new NotImplementedException ();
- }
- public static IEnumerable<TSource> TakeWhile<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> TakeWhile<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, int, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> SkipWhile<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> SkipWhile<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, int, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TResult> Select<TSource, TResult> (
- this IQueryable<TSource> source,
- Func<TSource, TResult> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TResult> Select<TSource, TResult> (
- this IQueryable<TSource> source,
- Func<TSource, int, TResult> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TResult> SelectMany<TSource, TResult> (
- this IQueryable<TSource> source,
- Func<TSource, IQueryable<TResult>> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TResult> SelectMany<TSource, TResult> (
- this IQueryable<TSource> source,
- Func<TSource, int, IQueryable<TResult>> selector)
- {
- throw new NotImplementedException ();
- }
-
- public static bool Any<TSource> (this IQueryable<TSource> source)
- {
- throw new NotImplementedException ();
- }
-
- public static bool Any<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static bool All<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static bool Contains<TSource> (this IQueryable<TSource> source, TSource value)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> Where<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<TSource> Where<TSource> (
- this IQueryable<TSource> source,
- Func<TSource, int, bool> predicate)
- {
- throw new NotImplementedException ();
- }
-
- public static IEnumerable<V> Join<TSource, U, K, V> (
- this IQueryable<TSource> outer,
- IQueryable<U> inner,
- Func<TSource, K> outerKeySelector,
- Func<U, K> innerKeySelector,
- Func<TSource, U, V> resultSelector)
- {
- throw new NotImplementedException ();
- }
- }
- }
|