private static Delegate CreateTypeMapping(Type typeT, SqlMetaData[] metaData) { var columns = metaData.Select((md, i) => (Thing) new Column(i, md.Name, Types.DBTypeToType[md.DbType])).ToList(); var result = Mapping.CreateFromDestination(Types.ReadablePublicThings(typeT), columns, typeT.Name); LambdaExpression lambdaExpression = CreateMappingLambda(typeT, result.Mapped); return(lambdaExpression.Compile()); }
/// <summary> /// Creates the mapping between <paramref name="source"/> and <paramref name="destination"/> using the DESTINATION to generate candidate names for the mapping /// </summary> public static MappingResult <Thing, Thing> CreateFromDestination(Type source, IReadOnlyCollection <Thing> destination, string removablePrefix = null) => CreateFromDestination(Types.ReadablePublicThings(source), destination, removablePrefix);
/// <summary> /// Creates the mapping between <paramref name="source"/> and <paramref name="destination"/> using the DESTINATION to generate candidate names for the mapping /// </summary> public static MappingResult <Thing, Thing> CreateFromDestination(Type source, Type destination, string removablePrefix = null) => CreateFromDestination(Types.ReadablePublicThings(source), Types.WriteablePublicThings(destination), removablePrefix);