Example #1
0
 /// <summary>
 /// Creates the mapping between <paramref name="sourceMappings"/> and <paramref name="destination"/> using the SOURCE to generate candidate names for the mapping
 /// </summary>
 internal static List <Mapping> CreateUsingSource(IReadOnlyCollection <Thing> sourceMappings, Type destination, string removablePrefix = null)
 => CreateUsingSource(sourceMappings, Types.WriteablePublicThings(destination), removablePrefix);
Example #2
0
 /// <summary>
 /// Creates the mapping between <paramref name="sourceMappings"/> and <paramref name="destinationMappings"/> using the DESTINATION to generate candidate names for the mapping
 /// </summary>
 internal static List <Mapping> CreateUsingDestination(Type source, IReadOnlyCollection <Thing> destinationMappings, string removablePrefix = null)
 => CreateUsingDestination(Types.WriteablePublicThings(source), destinationMappings, removablePrefix);
Example #3
0
 /// <summary>
 /// Creates the mapping between <paramref name="source"/> and <paramref name="destination"/> using the SOURCE to generate candidate names for the mapping
 /// </summary>
 internal static List <Mapping> CreateUsingSource(Type source, Type destination, string removablePrefix = null)
 => CreateUsingSource(Types.WriteablePublicThings(source), Types.WriteablePublicThings(destination), removablePrefix);
Example #4
0
        static Delegate CreateMapFunc(Type typeT, IReadOnlyCollection <Column> columns)
        {
            Contract.Requires(columns != null);
            Contract.Requires(typeT != null);
            Contract.Ensures(Contract.Result <Delegate>() != null);

            if (typeT.IsPrimitiveOrEnum() || typeT.IsNullable() || typeT == typeof(Guid) || typeT == typeof(DateTime))
            {
                return(CreatePrimativeMapFunc(typeT, columns));
            }

            var map         = Mapping.CreateUsingSource(columns.Cast <Thing>().ToList(), Types.WriteablePublicThings(typeT), typeT.Name);
            var readerParam = Expression.Parameter(typeof(DbDataReader), "reader");
            var resultParam = Expression.Parameter(typeT, "result");
            var block       = CreateMapBlock(typeT, map, readerParam, resultParam);
            var func        = typeof(Func <,>).MakeGenericType(new[] { typeof(DbDataReader), typeT });

            return(Expression.Lambda(func, block, new[] { readerParam }).Compile());
        }