反射在ef中的应用.pdf

时间:2022-09-10 09:48:52
【文件属性】:
文件名称:反射在ef中的应用.pdf
文件大小:55KB
文件格式:PDF
更新时间:2022-09-10 09:48:52
反射在ef中的应用 #region 3.2 根据指定条件 修改 +int ModifyBy(Expression> whereLambda) /// /// 2.3 根据指定条件 修改 /// /// 条件表达式 /// 要修改的属性名 /// 属性要修改的值 /// public int ModifyBy(Expression> whereLambda, string[] propertyNames, object[] perpertyValues) { //1.查询要修改的对象集合 var list = db.Set().Where(whereLambda).ToList(); //2.获取 要修改对象 的类型属性 Type t = typeof(T); //3.循环 要修改的 实体对象,并根据 要修改的属性名 修改对象对应的属性值 foreach (var item in list) { //循环 要修改的属性 名称, 并 反射取出 t 中的 属性对象 for (int index = 0; index < propertyNames.Length;index++ ) { //获取要修改的属性名 string pName = propertyNames[index]; //获取属性对象 PropertyInfo pi = t.GetProperty(pName);

网友评论