泛型方法
static TEntity MapEntity<TEntity>(SqlDataReader reader) where TEntity : class ,new() { var pros = typeof(TEntity).GetProperties(); var entity = new TEntity(); foreach (var item in pros) { var index = reader.GetOrdinal(item.Name); var data = reader.GetValue(index); item.SetValue(entity, Convert.ChangeType(data, item.PropertyType),null); } return entity; }