EF更新的时候,如果直接更新数据库里的记录,要以asnotracking执行查询,然后才能进行Entry操作!

This commit is contained in:
yubaolee 2015-11-23 23:01:54 +08:00
parent b5804105ed
commit 859300b331

View File

@ -28,7 +28,7 @@ namespace OpenAuth.Repository
/// </summary>
public T FindSingle(Expression<Func<T, bool>> exp)
{
return Context.Set<T>().FirstOrDefault(exp);
return Context.Set<T>().AsNoTracking().FirstOrDefault(exp);
}
/// <summary>