首页系统综合问题PropertyInfo 如何给属性中可为空的赋值

PropertyInfo 如何给属性中可为空的赋值

时间2022-12-09 23:30:23发布分享专员分类系统综合问题浏览82

public static T PopulateEntityFromCollection<T>(T entity, IData逐显儿溶亲Reader collection) w有胞货晚here T : new()

            //初始化 如果为null

            if (entity == null)

                entity = new T();

            //得到类型

            Type type = typ雷仍预东eof(T);

            //取得属性集合

            P意福远创粉群ropertyInfo[] pi = type.GetProperties();

            foreach (Pro斤袁众pertyInfo item in p让为县画心满还副编聚i)

                //给属性赋值

                if (colle脱重标晶技天风采雷ction[***.Name] != null)

                    item.SetValu景范族衡代改发盟雨地e(entity, Convert.ChangeType(collection[***.Nam省迫巴制经西e], item.Prope力杀距rtyType), null);

PropertyInfo 如何给属性中可为空的赋值

            return entity;

爱资源吧版权声明:以上文中内容来自网络,如有侵权请联系删除,谢谢。

PropertyInfo何给属空的赋PropertyInfo空的赋propertyinfo
windows 10 正式版电脑取消锁屏密码的方法 十大神级网站!拯救你的翻译问题