public static T Create <T>(this SqlResultRow row) { var ctor = GetConstructor <T>(); var obj = (T)ctor.Invoke(null); obj.SetValues(row); return(obj); }
public static T0 Create <T0, T1, T2, T3, T4, T5, T6, T7>(this SqlResultRow row, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) { var ctor = GetConstructor <T0, T1, T2, T3, T4, T5, T6, T7>(); var obj = (T0)ctor.Invoke(new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); obj.SetValues(row); return(obj); }
public static T0 Create <T0, T1, T2, T3>(this SqlResultRow row, T1 arg1, T2 arg2, T3 arg3) { var ctor = GetConstructor <T0, T1, T2, T3>(); var obj = (T0)ctor.Invoke(new object[] { arg1, arg2, arg3 }); obj.SetValues(row); return(obj); }
public static void SetValues <T>(this T src, SqlResultRow row) { foreach (var p in GetPropertyDictionary <T>()) { p.Key.SetValue(src, p.GetValue(row), null); } foreach (var f in GetFieldDictionary <T>()) { f.Key.SetValue(src, f.GetValue(row)); } }
private static object GetValue(this KeyValuePair <PropertyInfo, DbColumnAttribute> p, SqlResultRow row) { return(row[p.Value.ColumnName].GetValue(p.Key.PropertyType, p.Value?.DateFormat)); }
private static object GetValue(this KeyValuePair <FieldInfo, DbColumnAttribute> f, SqlResultRow row) { return(row[f.Value.ColumnName].GetValue(f.Key.FieldType, f.Value?.DateFormat)); }