利用反射快速给Model实体赋值
2013-01-15 16:50
369 查看
public class BaseModel<T> where T : new() { public static T Init(DataRow dr) { T t = new T(); Type infotype = typeof(T); //获取所有属性 PropertyInfo[] propertys = infotype.GetProperties(); //遍历属性并将datarow中字段的值赋值给同名属性 foreach (PropertyInfo pi in propertys) { infotype.GetProperty(pi.Name).SetValue(t, result, null); } return t; } } BaseModel<Student>.Init(dr)
相关文章推荐
- 利用反射快速给Model实体赋值
- 【转】利用反射快速给Model实体赋值
- 利用反射快速给Model实体赋值(二)
- 利用反射快速给Model实体赋值
- 利用反射快速给Model实体赋值
- 利用反射把DataTable自动赋值到Model实体(自动识别数据类型)
- 利用反射把DataTable自动赋值到Model实体(自动识别数据类型)
- 利用反射把DataTable自动赋值到Model实体(自动识别数据类型)
- 利用反射快速给Model实体赋
- java 利用反射机制,获取实体所有属性和方法,并对属性赋值
- java 利用反射机制,获取实体所有属性和方法,并对属性赋值
- 利用反射,泛型,静态方法快速获取表单值到Model。
- asp.net实现利用反射,泛型,静态方法快速获取表单值到Model的方法
- java 利用反射机制,获取实体所有属性和方法,并对属性赋值
- java 利用反射机制,获取实体所有属性和方法,并对属性赋值
- 利用反射,泛型,静态方法快速获取表单值到Model(转)
- 利用反射,泛型,静态方法快速获取表单值到Model
- asp.net实现利用反射,泛型,静态方法快速获取表单值到Model的方法
- java 利用反射机制,获取实体所有属性和方法,并对属性赋值
- java 利用反射机制,获取实体所有属性和方法,并对属性赋值