我有以下代码
public void SetDeparment(Guid employeeId,Guid departmentId)
{
var department = DepartmentRepository.GetById(departmentId);
Ensure.That(department).IsNotNull();
var employee = EmployeeRepository.GetById(employeeId);
department.AddEmployee(employee);
if(employee.Department==null)
{
employee.Department = new Department();
}
employee.Department = department;
EmployeeRepository.Update(employee);
UnitOfWork.Commit();
}
当我尝试调用此方法时,它会给出标题
中显示的错误在存储库更新中,我有:
public void Update(T entity)
{
DataBaseContext.Set<T>().AddOrUpdate(entity);
}
任何人都可以帮助我吗?感谢。