62,072
社区成员
发帖
与我相关
我的任务
分享
private void SetModelValue(BaseModel model, SqlDataReader dr)
{
Type t = this.GetType();
PropertyInfo[] myPropertyInfo;
myPropertyInfo = t.GetProperties();
for (int i = 0; i < myPropertyInfo.Length; i++)
{
//实体类中定义了可空数据类型就过不去,不定义可空类型就能过去 为什么?
myPropertyInfo[i].SetValue(model, ValueConversion.ConvertDBNullValue(dr[myPropertyInfo[i].Name]), null);
}
}
}
object obj = dr[dr[myPropertyInfo[i].Name]
if(obj != null)
{
myPropertyInfo[i].SetValue(model,obj,null);
}