12 people like it.

QuickLinq Helpers

Variations on some of the LINQ extension members which do not require a type annotation on the lambda argument when used from F#

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
[<AutoOpen>]
module QuickLinqHelpers = 
    open System
    open System.Linq
    open System.Linq.Expressions
    open System.Collections.Generic

    type IQueryable<'T> with 
        ///  A version of Queryable.OrderBy which does not require a type annotation on the argument when used from F#
        member x.OrderByQ(keySelector : Expression<Func<'T,'TKey>>) = System.Linq.Queryable.OrderBy(x,keySelector)
        ///  A version of Queryable.OrderByDescending which does not require a type annotation on the argument when used from F#
        member x.OrderByDescendingQ(keySelector : Expression<Func<'T,'TKey>>) = System.Linq.Queryable.OrderByDescending(x,keySelector)
        ///  A version of Queryable.Select which does not require a type annotation on the argument when used from F#
        member x.SelectQ(selector : Expression<Func<'T,'TResult>>) = System.Linq.Queryable.Select(x,selector)
        ///  A version of Queryable.SelectMany which does not require a type annotation on the argument when used from F#
        member x.SelectManyQ(selector : Expression<Func<'T,IEnumerable<'TResult>>>) = System.Linq.Queryable.SelectMany(x,selector)
        ///  A version of Queryable.SkipWhile which does not require a type annotation on the argument when used from F#
        member x.SkipWhileQ(predicate : Expression<Func<'T,bool>>) = System.Linq.Queryable.SkipWhile(x,predicate)
        ///  A version of Queryable.TakeWhile which does not require a type annotation on the argument when used from F#
        member x.TakeWhileQ(predicate : Expression<Func<'T,bool>>) = System.Linq.Queryable.TakeWhile(x,predicate)
        ///  A version of Queryable.Where which does not require a type annotation on the argument when used from F#
        member x.WhereQ(predicate : Expression<Func<'T,bool>>) = System.Linq.Queryable.Where(x,predicate)

    type IOrderedQueryable<'T> with 
        ///  A version of Queryable.ThenBy which does not require a type annotation on the argument when used from F#
        member x.ThenByQ(keySelector : Expression<Func<'T,'TKey>>) = System.Linq.Queryable.ThenBy(x,keySelector)
        ///  A version of Queryable.ThenByDescending which does not require a type annotation on the argument when used from F#
        member x.ThenByDescendingQ(keySelector : Expression<Func<'T,'TKey>>) = System.Linq.Queryable.ThenByDescending(x,keySelector)
Multiple items
type AutoOpenAttribute =
  inherit Attribute
  new : unit -> AutoOpenAttribute
  new : path:string -> AutoOpenAttribute
  member Path : string

Full name: Microsoft.FSharp.Core.AutoOpenAttribute

--------------------
new : unit -> AutoOpenAttribute
new : path:string -> AutoOpenAttribute
module QuickLinqHelpers

from Script
namespace System
namespace System.Linq
namespace System.Linq.Expressions
namespace System.Collections
namespace System.Collections.Generic
Multiple items
type IQueryable =
  member ElementType : Type
  member Expression : Expression
  member Provider : IQueryProvider

Full name: System.Linq.IQueryable

--------------------
type IQueryable<'T> =

Full name: System.Linq.IQueryable<_>
val x : IQueryable<'T>
member IQueryable.OrderByQ : keySelector:Expression<Func<'T,'TKey>> -> IOrderedQueryable<'T>

Full name: Script.QuickLinqHelpers.OrderByQ


  A version of Queryable.OrderBy which does not require a type annotation on the argument when used from F#
val keySelector : Expression<Func<'T,'TKey>>
Multiple items
type Expression =
  member CanReduce : bool
  member NodeType : ExpressionType
  member Reduce : unit -> Expression
  member ReduceAndCheck : unit -> Expression
  member ReduceExtensions : unit -> Expression
  member ToString : unit -> string
  member Type : Type
  static member Add : left:Expression * right:Expression -> BinaryExpression + 1 overload
  static member AddAssign : left:Expression * right:Expression -> BinaryExpression + 2 overloads
  static member AddAssignChecked : left:Expression * right:Expression -> BinaryExpression + 2 overloads
  ...

Full name: System.Linq.Expressions.Expression

--------------------
type Expression<'TDelegate> =
  inherit LambdaExpression
  member Compile : unit -> 'TDelegate + 1 overload
  member Update : body:Expression * parameters:IEnumerable<ParameterExpression> -> Expression<'TDelegate>

Full name: System.Linq.Expressions.Expression<_>
Multiple items
type Func<'TResult> =
  delegate of unit -> 'TResult

Full name: System.Func<_>

--------------------
type Func<'T,'TResult> =
  delegate of 'T -> 'TResult

Full name: System.Func<_,_>

--------------------
type Func<'T1,'T2,'TResult> =
  delegate of 'T1 * 'T2 -> 'TResult

Full name: System.Func<_,_,_>

--------------------
type Func<'T1,'T2,'T3,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 -> 'TResult

Full name: System.Func<_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 -> 'TResult

Full name: System.Func<_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 -> 'TResult

Full name: System.Func<_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'T16,'TResult> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 * 'T16 -> 'TResult

Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
type Queryable =
  static member Aggregate<'TSource> : source:IQueryable<'TSource> * func:Expression<Func<'TSource, 'TSource, 'TSource>> -> 'TSource + 2 overloads
  static member All<'TSource> : source:IQueryable<'TSource> * predicate:Expression<Func<'TSource, bool>> -> bool
  static member Any<'TSource> : source:IQueryable<'TSource> -> bool + 1 overload
  static member AsQueryable<'TElement> : source:IEnumerable<'TElement> -> IQueryable<'TElement> + 1 overload
  static member Average : source:IQueryable<int> -> float + 19 overloads
  static member Cast<'TResult> : source:IQueryable -> IQueryable<'TResult>
  static member Concat<'TSource> : source1:IQueryable<'TSource> * source2:IEnumerable<'TSource> -> IQueryable<'TSource>
  static member Contains<'TSource> : source:IQueryable<'TSource> * item:'TSource -> bool + 1 overload
  static member Count<'TSource> : source:IQueryable<'TSource> -> int + 1 overload
  static member DefaultIfEmpty<'TSource> : source:IQueryable<'TSource> -> IQueryable<'TSource> + 1 overload
  ...

Full name: System.Linq.Queryable
Queryable.OrderBy<'TSource,'TKey>(source: IQueryable<'TSource>, keySelector: Expression<Func<'TSource,'TKey>>) : IOrderedQueryable<'TSource>
Queryable.OrderBy<'TSource,'TKey>(source: IQueryable<'TSource>, keySelector: Expression<Func<'TSource,'TKey>>, comparer: IComparer<'TKey>) : IOrderedQueryable<'TSource>
member IQueryable.OrderByDescendingQ : keySelector:Expression<Func<'T,'TKey>> -> IOrderedQueryable<'T>

Full name: Script.QuickLinqHelpers.OrderByDescendingQ


  A version of Queryable.OrderByDescending which does not require a type annotation on the argument when used from F#
Queryable.OrderByDescending<'TSource,'TKey>(source: IQueryable<'TSource>, keySelector: Expression<Func<'TSource,'TKey>>) : IOrderedQueryable<'TSource>
Queryable.OrderByDescending<'TSource,'TKey>(source: IQueryable<'TSource>, keySelector: Expression<Func<'TSource,'TKey>>, comparer: IComparer<'TKey>) : IOrderedQueryable<'TSource>
member IQueryable.SelectQ : selector:Expression<Func<'T,'TResult>> -> IQueryable<'TResult>

Full name: Script.QuickLinqHelpers.SelectQ


  A version of Queryable.Select which does not require a type annotation on the argument when used from F#
val selector : Expression<Func<'T,'TResult>>
Queryable.Select<'TSource,'TResult>(source: IQueryable<'TSource>, selector: Expression<Func<'TSource,int,'TResult>>) : IQueryable<'TResult>
Queryable.Select<'TSource,'TResult>(source: IQueryable<'TSource>, selector: Expression<Func<'TSource,'TResult>>) : IQueryable<'TResult>
member IQueryable.SelectManyQ : selector:Expression<Func<'T,IEnumerable<'TResult>>> -> IQueryable<'TResult>

Full name: Script.QuickLinqHelpers.SelectManyQ


  A version of Queryable.SelectMany which does not require a type annotation on the argument when used from F#
val selector : Expression<Func<'T,IEnumerable<'TResult>>>
type IEnumerable<'T> =
  member GetEnumerator : unit -> IEnumerator<'T>

Full name: System.Collections.Generic.IEnumerable<_>
Queryable.SelectMany<'TSource,'TResult>(source: IQueryable<'TSource>, selector: Expression<Func<'TSource,int,IEnumerable<'TResult>>>) : IQueryable<'TResult>
Queryable.SelectMany<'TSource,'TResult>(source: IQueryable<'TSource>, selector: Expression<Func<'TSource,IEnumerable<'TResult>>>) : IQueryable<'TResult>
Queryable.SelectMany<'TSource,'TCollection,'TResult>(source: IQueryable<'TSource>, collectionSelector: Expression<Func<'TSource,IEnumerable<'TCollection>>>, resultSelector: Expression<Func<'TSource,'TCollection,'TResult>>) : IQueryable<'TResult>
Queryable.SelectMany<'TSource,'TCollection,'TResult>(source: IQueryable<'TSource>, collectionSelector: Expression<Func<'TSource,int,IEnumerable<'TCollection>>>, resultSelector: Expression<Func<'TSource,'TCollection,'TResult>>) : IQueryable<'TResult>
member IQueryable.SkipWhileQ : predicate:Expression<Func<'T,bool>> -> IQueryable<'T>

Full name: Script.QuickLinqHelpers.SkipWhileQ


  A version of Queryable.SkipWhile which does not require a type annotation on the argument when used from F#
val predicate : Expression<Func<'T,bool>>
type bool = Boolean

Full name: Microsoft.FSharp.Core.bool
Queryable.SkipWhile<'TSource>(source: IQueryable<'TSource>, predicate: Expression<Func<'TSource,int,bool>>) : IQueryable<'TSource>
Queryable.SkipWhile<'TSource>(source: IQueryable<'TSource>, predicate: Expression<Func<'TSource,bool>>) : IQueryable<'TSource>
member IQueryable.TakeWhileQ : predicate:Expression<Func<'T,bool>> -> IQueryable<'T>

Full name: Script.QuickLinqHelpers.TakeWhileQ


  A version of Queryable.TakeWhile which does not require a type annotation on the argument when used from F#
Queryable.TakeWhile<'TSource>(source: IQueryable<'TSource>, predicate: Expression<Func<'TSource,int,bool>>) : IQueryable<'TSource>
Queryable.TakeWhile<'TSource>(source: IQueryable<'TSource>, predicate: Expression<Func<'TSource,bool>>) : IQueryable<'TSource>
member IQueryable.WhereQ : predicate:Expression<Func<'T,bool>> -> IQueryable<'T>

Full name: Script.QuickLinqHelpers.WhereQ


  A version of Queryable.Where which does not require a type annotation on the argument when used from F#
Queryable.Where<'TSource>(source: IQueryable<'TSource>, predicate: Expression<Func<'TSource,int,bool>>) : IQueryable<'TSource>
Queryable.Where<'TSource>(source: IQueryable<'TSource>, predicate: Expression<Func<'TSource,bool>>) : IQueryable<'TSource>
Multiple items
type IOrderedQueryable =

Full name: System.Linq.IOrderedQueryable

--------------------
type IOrderedQueryable<'T> =

Full name: System.Linq.IOrderedQueryable<_>
val x : IOrderedQueryable<'T>
member IOrderedQueryable.ThenByQ : keySelector:Expression<Func<'T,'TKey>> -> IOrderedQueryable<'T>

Full name: Script.QuickLinqHelpers.ThenByQ


  A version of Queryable.ThenBy which does not require a type annotation on the argument when used from F#
Queryable.ThenBy<'TSource,'TKey>(source: IOrderedQueryable<'TSource>, keySelector: Expression<Func<'TSource,'TKey>>) : IOrderedQueryable<'TSource>
Queryable.ThenBy<'TSource,'TKey>(source: IOrderedQueryable<'TSource>, keySelector: Expression<Func<'TSource,'TKey>>, comparer: IComparer<'TKey>) : IOrderedQueryable<'TSource>
member IOrderedQueryable.ThenByDescendingQ : keySelector:Expression<Func<'T,'TKey>> -> IOrderedQueryable<'T>

Full name: Script.QuickLinqHelpers.ThenByDescendingQ


  A version of Queryable.ThenByDescending which does not require a type annotation on the argument when used from F#
Queryable.ThenByDescending<'TSource,'TKey>(source: IOrderedQueryable<'TSource>, keySelector: Expression<Func<'TSource,'TKey>>) : IOrderedQueryable<'TSource>
Queryable.ThenByDescending<'TSource,'TKey>(source: IOrderedQueryable<'TSource>, keySelector: Expression<Func<'TSource,'TKey>>, comparer: IComparer<'TKey>) : IOrderedQueryable<'TSource>
Raw view Test code New version

More information

Link:http://fssnip.net/g0
Posted:11 years ago
Author:Don Syme
Tags: linq;queries