标签:
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; }
标签:
原文地址:http://www.cnblogs.com/crazyair/p/4438791.html