Beispiel #1
0
        /// <summary>
        /// Generate an expression for a constructor mapping
        /// </summary>
        static Expression GenerateCtorMapping(Expression reader, CtorMapping mapping)
        {
            var parsMapping = mapping.ConstructorColumnMapping.Select(x => GenerateMapping(reader, x));
            var ctorCall    = Expression.New(mapping.Constructor, parsMapping);

            var propsSet = mapping.PropertyMapping.Select(x => Expression.Bind(x.Key, GenerateMapping(reader, x.Value)));
            var init     = Expression.MemberInit(ctorCall, propsSet);

            return(init);
        }
Beispiel #2
0
 /// <summary>
 /// Generate the constructor call for creating the item instance
 /// </summary>
 internal static Expression GenerateConsCall(Expression reader, CtorMapping mapping)
 {
     return(Expression.New(mapping.Constructor));
 }