public static t CastAs <t> (this IDataRecord record) where t : new() { var valtypeof = typeof(t); var ret = new t(); record .AsEnumerable() .ForEach(a => ret = ret.Set(a.Key, a.Value)); return(ret); }