标签:core value comm result UNC virtual pos text res
using System.Linq.Expressions;
//用表达式树,部分字段 Expression<Func<CourseSchedule, object>>[] updatedProperties = { p => p.createtime, };
调用Helper类
_courseScheduleRepository.Value.UpdateEntity(schedule, updatedProperties, true);
Helper类
/// <summary> /// 更新部分字段 /// </summary> public virtual int UpdateEntity(T entity, Expression<Func<T, object>>[] updatedProperties, bool IsCommit = true) { int result = 0; _dbContext.Set<T>().Attach(entity); if (updatedProperties.Any()) { foreach (var property in updatedProperties) { _dbContext.Entry<T>(entity).Property(property).IsModified = true; } } if (IsCommit) { result = _UnitOfWork.Commit(); } return result; }
标签:core value comm result UNC virtual pos text res
原文地址:https://www.cnblogs.com/puzi0315/p/12892101.html