10 people like it.

Using AutoMapper with F#

This wrapper will handle translating F# quotations into LINQ expressions that AutoMapper can use, enabling AutoMapper to be configured from F# code. You must reference AutoMapper and FSharp.PowerPack.Linq, or include Linq.fsi and Linq.fs from the PowerPack into your project.

  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: 
 29: 
 30: 
 31: 
 32: 
 33: 
 34: 
 35: 
 36: 
 37: 
 38: 
 39: 
 40: 
 41: 
 42: 
 43: 
 44: 
 45: 
 46: 
 47: 
 48: 
 49: 
 50: 
 51: 
 52: 
 53: 
 54: 
 55: 
 56: 
 57: 
 58: 
 59: 
 60: 
 61: 
 62: 
 63: 
 64: 
 65: 
 66: 
 67: 
 68: 
 69: 
 70: 
 71: 
 72: 
 73: 
 74: 
 75: 
 76: 
 77: 
 78: 
 79: 
 80: 
 81: 
 82: 
 83: 
 84: 
 85: 
 86: 
 87: 
 88: 
 89: 
 90: 
 91: 
 92: 
 93: 
 94: 
 95: 
 96: 
 97: 
 98: 
 99: 
100: 
101: 
102: 
103: 
104: 
105: 
106: 
107: 
108: 
109: 
110: 
111: 
112: 
113: 
114: 
115: 
116: 
117: 
#if INTERACTIVE
#r "FSharp.PowerPack.Linq.dll"
#r "AutoMapper.dll" 
#endif

namespace Microsoft.FSharp.Quotations

module Expr =
    open System
    open System.Linq.Expressions
    open Microsoft.FSharp.Quotations
    open Microsoft.FSharp.Linq.QuotationEvaluation

    /// Translates simple F# quotation to LINQ expression
    /// (the function supports only variables, property getters,
    /// method calls and static method calls)
    // http://www.fssnip.net/c6
    let rec private translateSimpleExpr expr =
        match expr with
        | Patterns.Var(var) ->
            // Variable access
            Expression.Variable(var.Type, var.Name) :> Expression
        | Patterns.PropertyGet(Some inst, pi, []) ->
            // Getter of an instance property
            let instExpr = translateSimpleExpr inst
            Expression.Property(instExpr, pi) :> Expression
        | Patterns.Call(Some inst, mi, args) ->
            // Method call - translate instance & arguments recursively
            let argsExpr = Seq.map translateSimpleExpr args
            let instExpr = translateSimpleExpr inst
            Expression.Call(instExpr, mi, argsExpr) :> Expression
        | Patterns.Call(None, mi, args) ->
            // Static method call - no instance
            let argsExpr = Seq.map translateSimpleExpr args
            Expression.Call(mi, argsExpr) :> Expression
        | _ -> failwith "not supported"

    // http://stackoverflow.com/questions/10658207/using-automapper-with-f
    let ToAutoMapperGet (expr:Expr<'a -> 'b>) =
        match expr with
        | Patterns.Lambda(v, body) ->
            // Build LINQ style lambda expression
            let bodyExpr = Expression.Convert(translateSimpleExpr body, typeof<obj>)
            let paramExpr = Expression.Parameter(v.Type, v.Name)
            Expression.Lambda<Func<'a, obj>>(bodyExpr, paramExpr)
        | _ -> failwith "not supported"

    // http://stackoverflow.com/questions/10647198/how-to-convert-expra-b-to-expressionfunca-obj
    let ToFuncExpression (expr:Expr<'a -> 'b>) =
        let call = expr.ToLinqExpression() :?> MethodCallExpression
        let lambda = call.Arguments.[0] :?> LambdaExpression
        Expression.Lambda<Func<'a, 'b>>(lambda.Body, lambda.Parameters) 

namespace AutoMapper

/// Functions for working with AutoMapper using F# quotations,
/// in a manner that is compatible with F# type-inference.
module AutoMap =
    open System
    open Microsoft.FSharp.Quotations

    let forMember (destMember: Expr<'dest -> 'mbr>) 
                  (memberOpts: IMemberConfigurationExpression<'source> -> unit) 
                  (map: IMappingExpression<'source, 'dest>) =
        map.ForMember(Expr.ToAutoMapperGet destMember, memberOpts)

    let mapMember destMember (sourceMap:Expr<'source -> 'mapped>) =
        forMember destMember (fun o -> o.MapFrom(Expr.ToFuncExpression sourceMap))

    let ignoreMember destMember =
        forMember destMember (fun o -> o.Ignore())

    let forMemberName (destMember: string) 
                      (memberOpts: IMemberConfigurationExpression<'source> -> unit) 
                      (map: IMappingExpression<'source, 'dest>) =
        map.ForMember(destMember, memberOpts)

    let mapMemberName destMember (sourceMap:Expr<'source -> 'mapped>) =
        forMemberName destMember (fun o -> o.MapFrom(Expr.ToFuncExpression sourceMap))

    let ignoreMemberName destMember =
        forMemberName destMember (fun o -> o.Ignore())
        
[<AutoOpen>]
module AutoMapperExtensions =
    open System
    open System.Collections.Generic

    let inline isNull x = Object.ReferenceEquals(x, null)
    
    type IList<'a> with
        member this.MapTo<'b> () =
            if isNull this then nullArg "this"
            Mapper.Map(this, this.GetType(), typeof<ResizeArray<'b>>) :?> IList<'b>

    type IEnumerable<'a> with
        member this.MapTo<'b> () =
            if isNull this then nullArg "this"
            Mapper.Map(this, this.GetType(), typeof<IEnumerable<'b>>) :?> IEnumerable<'b>

    type System.Collections.IEnumerable with
        member this.MapTo<'b> () =
            if isNull this then nullArg "this"
            Mapper.Map(this, this.GetType(), typeof<IEnumerable<'b>>) :?> IEnumerable<'b>

    type System.Object with
        member this.MapTo<'b> () =
            if isNull this then nullArg "this"
            Mapper.Map(this, this.GetType(), typeof<'b>) :?> 'b

        member this.MapPropertiesToInstance<'b>(value:'b) =
            if isNull this then nullArg "this"
            Mapper.Map(this, value, this.GetType(), typeof<'b>) :?> 'b

        member this.DynamicMapTo<'b> () =
            if isNull this then nullArg "this"
            Mapper.DynamicMap(this, this.GetType(), typeof<'b>) :?> 'b
namespace Microsoft
namespace Microsoft.FSharp
namespace Microsoft.FSharp.Quotations
namespace System
namespace System.Linq
namespace System.Linq.Expressions
namespace Microsoft.FSharp.Linq
val private translateSimpleExpr : expr:Expr -> Expression

Full name: Microsoft.FSharp.Quotations.Expr.translateSimpleExpr


 Translates simple F# quotation to LINQ expression
 (the function supports only variables, property getters,
 method calls and static method calls)
val expr : Expr
module Patterns

from Microsoft.FSharp.Quotations
active recognizer Var: Expr -> Var option

Full name: Microsoft.FSharp.Quotations.Patterns.( |Var|_| )
val var : Var
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<_>
Expression.Variable(type: Type) : ParameterExpression
Expression.Variable(type: Type, name: string) : ParameterExpression
property Var.Type: Type
property Var.Name: string
active recognizer PropertyGet: Expr -> (Expr option * Reflection.PropertyInfo * Expr list) option

Full name: Microsoft.FSharp.Quotations.Patterns.( |PropertyGet|_| )
union case Option.Some: Value: 'T -> Option<'T>
val inst : Expr
val pi : Reflection.PropertyInfo
val instExpr : Expression
Expression.Property(expression: Expression, propertyAccessor: Reflection.MethodInfo) : MemberExpression
Expression.Property(expression: Expression, property: Reflection.PropertyInfo) : MemberExpression
Expression.Property(expression: Expression, propertyName: string) : MemberExpression
Expression.Property(expression: Expression, type: Type, propertyName: string) : MemberExpression
Expression.Property(instance: Expression, indexer: Reflection.PropertyInfo, arguments: Collections.Generic.IEnumerable<Expression>) : IndexExpression
Expression.Property(instance: Expression, indexer: Reflection.PropertyInfo, [<ParamArray>] arguments: Expression []) : IndexExpression
Expression.Property(instance: Expression, propertyName: string, [<ParamArray>] arguments: Expression []) : IndexExpression
active recognizer Call: Expr -> (Expr option * Reflection.MethodInfo * Expr list) option

Full name: Microsoft.FSharp.Quotations.Patterns.( |Call|_| )
val mi : Reflection.MethodInfo
val args : Expr list
val argsExpr : seq<Expression>
module Seq

from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
Expression.Call(instance: Expression, method: Reflection.MethodInfo) : MethodCallExpression
   (+0 other overloads)
Expression.Call(method: Reflection.MethodInfo, arguments: Collections.Generic.IEnumerable<Expression>) : MethodCallExpression
   (+0 other overloads)
Expression.Call(method: Reflection.MethodInfo, [<ParamArray>] arguments: Expression []) : MethodCallExpression
   (+0 other overloads)
Expression.Call(method: Reflection.MethodInfo, arg0: Expression) : MethodCallExpression
   (+0 other overloads)
Expression.Call(instance: Expression, method: Reflection.MethodInfo, arguments: Collections.Generic.IEnumerable<Expression>) : MethodCallExpression
   (+0 other overloads)
Expression.Call(instance: Expression, method: Reflection.MethodInfo, [<ParamArray>] arguments: Expression []) : MethodCallExpression
   (+0 other overloads)
Expression.Call(method: Reflection.MethodInfo, arg0: Expression, arg1: Expression) : MethodCallExpression
   (+0 other overloads)
Expression.Call(type: Type, methodName: string, typeArguments: Type [], [<ParamArray>] arguments: Expression []) : MethodCallExpression
   (+0 other overloads)
Expression.Call(instance: Expression, methodName: string, typeArguments: Type [], [<ParamArray>] arguments: Expression []) : MethodCallExpression
   (+0 other overloads)
Expression.Call(instance: Expression, method: Reflection.MethodInfo, arg0: Expression, arg1: Expression) : MethodCallExpression
   (+0 other overloads)
union case Option.None: Option<'T>
val failwith : message:string -> 'T

Full name: Microsoft.FSharp.Core.Operators.failwith
val ToAutoMapperGet : expr:Expr<('a -> 'b)> -> Expression<Func<'a,obj>>

Full name: Microsoft.FSharp.Quotations.Expr.ToAutoMapperGet
val expr : Expr<('a -> 'b)>
Multiple items
type Expr =
  override Equals : obj:obj -> bool
  member GetFreeVars : unit -> seq<Var>
  member Substitute : substitution:(Var -> Expr option) -> Expr
  member ToString : full:bool -> string
  member CustomAttributes : Expr list
  member Type : Type
  static member AddressOf : target:Expr -> Expr
  static member AddressSet : target:Expr * value:Expr -> Expr
  static member Application : functionExpr:Expr * argument:Expr -> Expr
  static member Applications : functionExpr:Expr * arguments:Expr list list -> Expr
  ...

Full name: Microsoft.FSharp.Quotations.Expr

--------------------
type Expr<'T> =
  inherit Expr
  member Raw : Expr

Full name: Microsoft.FSharp.Quotations.Expr<_>
active recognizer Lambda: Expr -> (Var * Expr) option

Full name: Microsoft.FSharp.Quotations.Patterns.( |Lambda|_| )
val v : Var
val body : Expr
val bodyExpr : UnaryExpression
Expression.Convert(expression: Expression, type: Type) : UnaryExpression
Expression.Convert(expression: Expression, type: Type, method: Reflection.MethodInfo) : UnaryExpression
val typeof<'T> : Type

Full name: Microsoft.FSharp.Core.Operators.typeof
type obj = Object

Full name: Microsoft.FSharp.Core.obj
val paramExpr : ParameterExpression
Expression.Parameter(type: Type) : ParameterExpression
Expression.Parameter(type: Type, name: string) : ParameterExpression
Expression.Lambda(body: Expression, parameters: Collections.Generic.IEnumerable<ParameterExpression>) : LambdaExpression
   (+0 other overloads)
Expression.Lambda(body: Expression, [<ParamArray>] parameters: ParameterExpression []) : LambdaExpression
   (+0 other overloads)
Expression.Lambda<'TDelegate>(body: Expression, parameters: Collections.Generic.IEnumerable<ParameterExpression>) : Expression<'TDelegate>
   (+0 other overloads)
Expression.Lambda<'TDelegate>(body: Expression, [<ParamArray>] parameters: ParameterExpression []) : Expression<'TDelegate>
   (+0 other overloads)
Expression.Lambda(body: Expression, name: string, parameters: Collections.Generic.IEnumerable<ParameterExpression>) : LambdaExpression
   (+0 other overloads)
Expression.Lambda(delegateType: Type, body: Expression, parameters: Collections.Generic.IEnumerable<ParameterExpression>) : LambdaExpression
   (+0 other overloads)
Expression.Lambda(delegateType: Type, body: Expression, [<ParamArray>] parameters: ParameterExpression []) : LambdaExpression
   (+0 other overloads)
Expression.Lambda(body: Expression, tailCall: bool, parameters: Collections.Generic.IEnumerable<ParameterExpression>) : LambdaExpression
   (+0 other overloads)
Expression.Lambda(body: Expression, tailCall: bool, [<ParamArray>] parameters: ParameterExpression []) : LambdaExpression
   (+0 other overloads)
Expression.Lambda<'TDelegate>(body: Expression, name: string, parameters: Collections.Generic.IEnumerable<ParameterExpression>) : Expression<'TDelegate>
   (+0 other overloads)
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<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
val ToFuncExpression : expr:Expr<('a -> 'b)> -> Expression<Func<'a,'b>>

Full name: Microsoft.FSharp.Quotations.Expr.ToFuncExpression
val call : MethodCallExpression
type MethodCallExpression =
  inherit Expression
  member Arguments : ReadOnlyCollection<Expression>
  member Method : MethodInfo
  member NodeType : ExpressionType
  member Object : Expression
  member Type : Type
  member Update : object:Expression * arguments:IEnumerable<Expression> -> MethodCallExpression

Full name: System.Linq.Expressions.MethodCallExpression
val lambda : LambdaExpression
property MethodCallExpression.Arguments: Collections.ObjectModel.ReadOnlyCollection<Expression>
type LambdaExpression =
  inherit Expression
  member Body : Expression
  member Compile : unit -> Delegate + 1 overload
  member CompileToMethod : method:MethodBuilder -> unit + 1 overload
  member Name : string
  member NodeType : ExpressionType
  member Parameters : ReadOnlyCollection<ParameterExpression>
  member ReturnType : Type
  member TailCall : bool
  member Type : Type

Full name: System.Linq.Expressions.LambdaExpression
property LambdaExpression.Body: Expression
property LambdaExpression.Parameters: Collections.ObjectModel.ReadOnlyCollection<ParameterExpression>
namespace AutoMapper
val forMember : destMember:Expr<('dest -> 'mbr)> -> memberOpts:(IMemberConfigurationExpression<'source> -> unit) -> map:IMappingExpression<'source,'dest> -> IMappingExpression<'source,'dest>

Full name: AutoMapper.AutoMap.forMember
val destMember : Expr<('dest -> 'mbr)>
Multiple items
module Expr

from Microsoft.FSharp.Quotations

--------------------
type Expr =
  override Equals : obj:obj -> bool
  member GetFreeVars : unit -> seq<Var>
  member Substitute : substitution:(Var -> Expr option) -> Expr
  member ToString : full:bool -> string
  member CustomAttributes : Expr list
  member Type : Type
  static member AddressOf : target:Expr -> Expr
  static member AddressSet : target:Expr * value:Expr -> Expr
  static member Application : functionExpr:Expr * argument:Expr -> Expr
  static member Applications : functionExpr:Expr * arguments:Expr list list -> Expr
  ...

Full name: Microsoft.FSharp.Quotations.Expr

--------------------
type Expr<'T> =
  inherit Expr
  member Raw : Expr

Full name: Microsoft.FSharp.Quotations.Expr<_>
val memberOpts : (IMemberConfigurationExpression<'source> -> unit)
Multiple items
type IMemberConfigurationExpression =
  member MapFrom : sourceMember:string -> unit

Full name: AutoMapper.IMemberConfigurationExpression

--------------------
type IMemberConfigurationExpression<'TSource> =
  member Condition : condition:Func<'TSource, bool> -> unit + 1 overload
  member DoNotUseDestinationValue : unit -> unit
  member ExplicitExpansion : unit -> unit
  member Ignore : unit -> unit
  member MapFrom<'TMember> : sourceMember:Expression<Func<'TSource, 'TMember>> -> unit + 1 overload
  member NullSubstitute : nullSubstitute:obj -> unit
  member PreCondition : condition:Func<'TSource, bool> -> unit + 1 overload
  member ResolveUsing<'TValueResolver> : unit -> IResolverConfigurationExpression<'TSource, 'TValueResolver> + 5 overloads
  member SetMappingOrder : mappingOrder:int -> unit
  member UseDestinationValue : unit -> unit
  ...

Full name: AutoMapper.IMemberConfigurationExpression<_>
type unit = Unit

Full name: Microsoft.FSharp.Core.unit
val map : IMappingExpression<'source,'dest>
Multiple items
type IMappingExpression =
  member AfterMap<'TMappingAction> : unit -> IMappingExpression + 1 overload
  member As : typeOverride:Type -> unit
  member BeforeMap<'TMappingAction> : unit -> IMappingExpression + 1 overload
  member ConstructProjectionUsing : ctor:LambdaExpression -> IMappingExpression
  member ConstructUsing : ctor:Func<ResolutionContext, obj> -> IMappingExpression + 1 overload
  member ConstructUsingServiceLocator : unit -> IMappingExpression
  member ConvertUsing<'TTypeConverter> : unit -> unit + 1 overload
  member ForAllMembers : memberOptions:Action<IMemberConfigurationExpression> -> unit
  member ForCtorParam : ctorParamName:string * paramOptions:Action<ICtorParamConfigurationExpression<obj>> -> IMappingExpression
  member ForMember : name:string * memberOptions:Action<IMemberConfigurationExpression> -> IMappingExpression
  ...

Full name: AutoMapper.IMappingExpression

--------------------
type IMappingExpression<'TSource,'TDestination> =
  member AfterMap<'TMappingAction> : unit -> IMappingExpression<'TSource, 'TDestination> + 1 overload
  member As<'T> : unit -> unit
  member BeforeMap<'TMappingAction> : unit -> IMappingExpression<'TSource, 'TDestination> + 1 overload
  member ConstructProjectionUsing : ctor:Expression<Func<'TSource, 'TDestination>> -> IMappingExpression<'TSource, 'TDestination>
  member ConstructUsing : ctor:Func<'TSource, 'TDestination> -> IMappingExpression<'TSource, 'TDestination> + 1 overload
  member ConstructUsingServiceLocator : unit -> IMappingExpression<'TSource, 'TDestination>
  member ConvertUsing<'TTypeConverter> : unit -> unit + 4 overloads
  member ForAllMembers : memberOptions:Action<IMemberConfigurationExpression<'TSource>> -> unit
  member ForCtorParam : ctorParamName:string * paramOptions:Action<ICtorParamConfigurationExpression<'TSource>> -> IMappingExpression<'TSource, 'TDestination>
  member ForMember : destinationMember:Expression<Func<'TDestination, obj>> * memberOptions:Action<IMemberConfigurationExpression<'TSource>> -> IMappingExpression<'TSource, 'TDestination> + 1 overload
  ...

Full name: AutoMapper.IMappingExpression<_,_>
IMappingExpression.ForMember(name: string, memberOptions: Action<IMemberConfigurationExpression<'source>>) : IMappingExpression<'source,'dest>
IMappingExpression.ForMember(destinationMember: Linq.Expressions.Expression<Func<'dest,obj>>, memberOptions: Action<IMemberConfigurationExpression<'source>>) : IMappingExpression<'source,'dest>
val ToAutoMapperGet : expr:Expr<('a -> 'b)> -> Linq.Expressions.Expression<Func<'a,obj>>

Full name: Microsoft.FSharp.Quotations.Expr.ToAutoMapperGet
val mapMember : destMember:Expr<('a -> 'b)> -> sourceMap:Expr<('source -> 'mapped)> -> (IMappingExpression<'source,'a> -> IMappingExpression<'source,'a>)

Full name: AutoMapper.AutoMap.mapMember
val destMember : Expr<('a -> 'b)>
val sourceMap : Expr<('source -> 'mapped)>
val o : IMemberConfigurationExpression<'source>
IMemberConfigurationExpression.MapFrom<'TMember>(property: string) : unit
IMemberConfigurationExpression.MapFrom<'TMember>(sourceMember: Linq.Expressions.Expression<Func<'source,'TMember>>) : unit
val ToFuncExpression : expr:Expr<('a -> 'b)> -> Linq.Expressions.Expression<Func<'a,'b>>

Full name: Microsoft.FSharp.Quotations.Expr.ToFuncExpression
val ignoreMember : destMember:Expr<('a -> 'b)> -> (IMappingExpression<'c,'a> -> IMappingExpression<'c,'a>)

Full name: AutoMapper.AutoMap.ignoreMember
val o : IMemberConfigurationExpression<'c>
IMemberConfigurationExpression.Ignore() : unit
val forMemberName : destMember:string -> memberOpts:(IMemberConfigurationExpression<'source> -> unit) -> map:IMappingExpression<'source,'dest> -> IMappingExpression<'source,'dest>

Full name: AutoMapper.AutoMap.forMemberName
val destMember : string
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = String

Full name: Microsoft.FSharp.Core.string
val mapMemberName : destMember:string -> sourceMap:Expr<('source -> 'mapped)> -> (IMappingExpression<'source,'a> -> IMappingExpression<'source,'a>)

Full name: AutoMapper.AutoMap.mapMemberName
val ignoreMemberName : destMember:string -> (IMappingExpression<'a,'b> -> IMappingExpression<'a,'b>)

Full name: AutoMapper.AutoMap.ignoreMemberName
val o : IMemberConfigurationExpression<'a>
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 AutoMapperExtensions

from AutoMapper
namespace System.Collections
namespace System.Collections.Generic
val isNull : x:'a -> bool

Full name: AutoMapper.AutoMapperExtensions.isNull
val x : 'a
Multiple items
type Object =
  new : unit -> obj
  member Equals : obj:obj -> bool
  member GetHashCode : unit -> int
  member GetType : unit -> Type
  member ToString : unit -> string
  static member Equals : objA:obj * objB:obj -> bool
  static member ReferenceEquals : objA:obj * objB:obj -> bool

Full name: System.Object

--------------------
Object() : unit
Object.ReferenceEquals(objA: obj, objB: obj) : bool
type IList<'T> =
  member IndexOf : item:'T -> int
  member Insert : index:int * item:'T -> unit
  member Item : int -> 'T with get, set
  member RemoveAt : index:int -> unit

Full name: System.Collections.Generic.IList<_>
val this : IList<'T>
Multiple items
member IList.MapTo : unit -> IList<'b>

Full name: AutoMapper.AutoMapperExtensions.MapTo

--------------------
type MapToAttribute =
  inherit SourceToDestinationMapperAttribute
  new : matchingName:string -> MapToAttribute
  member IsMatch : typeInfo:TypeDetails * memberInfo:MemberInfo * destType:Type * nameToSearch:string -> bool
  member MatchingName : string

Full name: AutoMapper.MapToAttribute

--------------------
MapToAttribute(matchingName: string) : unit
val nullArg : argumentName:string -> 'T

Full name: Microsoft.FSharp.Core.Operators.nullArg
type Mapper =
  static member AddGlobalIgnore : startingwith:string -> unit
  static member AddProfile<'TProfile> : unit -> unit + 1 overload
  static member AllowNullDestinationValues : bool with get, set
  static member AssertConfigurationIsValid : unit -> unit + 3 overloads
  static member Configuration : IConfiguration
  static member CreateMap<'TSource, 'TDestination> : unit -> IMappingExpression<'TSource, 'TDestination> + 3 overloads
  static member CreateProfile : profileName:string -> IProfileExpression + 1 overload
  static member DynamicMap<'TSource, 'TDestination> : source:'TSource -> 'TDestination + 4 overloads
  static member Engine : IMappingEngine
  static member FindTypeMapFor<'TSource, 'TDestination> : unit -> TypeMap + 1 overload
  ...

Full name: AutoMapper.Mapper
Mapper.Map<'TSource,'TDestination>(source: 'TSource) : 'TDestination
Mapper.Map<'TDestination>(source: obj) : 'TDestination
Mapper.Map<'TSource,'TDestination>(source: 'TSource, opts: Action<IMappingOperationOptions<'TSource,'TDestination>>) : 'TDestination
Mapper.Map<'TSource,'TDestination>(source: 'TSource, destination: 'TDestination) : 'TDestination
Mapper.Map<'TDestination>(source: obj, opts: Action<IMappingOperationOptions>) : 'TDestination
Mapper.Map(source: obj, sourceType: Type, destinationType: Type) : obj
Mapper.Map<'TSource,'TDestination>(source: 'TSource, destination: 'TDestination, opts: Action<IMappingOperationOptions<'TSource,'TDestination>>) : 'TDestination
Mapper.Map(source: obj, destination: obj, sourceType: Type, destinationType: Type) : obj
Mapper.Map(source: obj, sourceType: Type, destinationType: Type, opts: Action<IMappingOperationOptions>) : obj
Mapper.Map(source: obj, destination: obj, sourceType: Type, destinationType: Type, opts: Action<IMappingOperationOptions>) : obj
Object.GetType() : Type
type ResizeArray<'T> = List<'T>

Full name: Microsoft.FSharp.Collections.ResizeArray<_>
type IEnumerable<'T> =
  member GetEnumerator : unit -> IEnumerator<'T>

Full name: System.Collections.Generic.IEnumerable<_>
val this : IEnumerable<'T>
Multiple items
member IEnumerable.MapTo : unit -> IEnumerable<'b>

Full name: AutoMapper.AutoMapperExtensions.MapTo

--------------------
type MapToAttribute =
  inherit SourceToDestinationMapperAttribute
  new : matchingName:string -> MapToAttribute
  member IsMatch : typeInfo:TypeDetails * memberInfo:MemberInfo * destType:Type * nameToSearch:string -> bool
  member MatchingName : string

Full name: AutoMapper.MapToAttribute

--------------------
MapToAttribute(matchingName: string) : unit
type IEnumerable =
  member GetEnumerator : unit -> IEnumerator

Full name: System.Collections.IEnumerable
val this : Collections.IEnumerable
Multiple items
member Collections.IEnumerable.MapTo : unit -> IEnumerable<'b>

Full name: AutoMapper.AutoMapperExtensions.MapTo

--------------------
type MapToAttribute =
  inherit SourceToDestinationMapperAttribute
  new : matchingName:string -> MapToAttribute
  member IsMatch : typeInfo:TypeDetails * memberInfo:MemberInfo * destType:Type * nameToSearch:string -> bool
  member MatchingName : string

Full name: AutoMapper.MapToAttribute

--------------------
MapToAttribute(matchingName: string) : unit
val this : Object
Multiple items
member Object.MapTo : unit -> 'b

Full name: AutoMapper.AutoMapperExtensions.MapTo

--------------------
type MapToAttribute =
  inherit SourceToDestinationMapperAttribute
  new : matchingName:string -> MapToAttribute
  member IsMatch : typeInfo:TypeDetails * memberInfo:MemberInfo * destType:Type * nameToSearch:string -> bool
  member MatchingName : string

Full name: AutoMapper.MapToAttribute

--------------------
MapToAttribute(matchingName: string) : unit
member Object.MapPropertiesToInstance : value:'b -> 'b

Full name: AutoMapper.AutoMapperExtensions.MapPropertiesToInstance
val value : 'b
member Object.DynamicMapTo : unit -> 'b

Full name: AutoMapper.AutoMapperExtensions.DynamicMapTo
Mapper.DynamicMap<'TDestination>(source: obj) : 'TDestination
Mapper.DynamicMap<'TSource,'TDestination>(source: 'TSource) : 'TDestination
Mapper.DynamicMap<'TSource,'TDestination>(source: 'TSource, destination: 'TDestination) : unit
Mapper.DynamicMap(source: obj, sourceType: Type, destinationType: Type) : obj
Mapper.DynamicMap(source: obj, destination: obj, sourceType: Type, destinationType: Type) : unit
Next Version Raw view Test code New version

More information

Link:http://fssnip.net/c7
Posted:12 years ago
Author:Joel Mueller
Tags: linq , automapper