付出与汲取

反射获取可空属性的数据类型

 

 

 

 

//获取T类型的属性类型和值
PropertyInfo[] pis = entity.GetType().GetProperties();

//如果当前列为可空类型,则获取其基类数据类型
//如果不获取基类类型的话,则当前列的数据类型为
if(typeColumn.IsGenericType && typeColumn.GetGenericTypeDefinition() == typeof(Nullable<>))
{
typeName = typeColumn.GetGenericArguments()[0].Name;
}
else
{
typeName = typeColumn.Name;
}

posted on 2020-08-18 09:37  付出与汲取  阅读(420)  评论(1编辑  收藏  举报

导航