当调用DbContext.SaveChange()方法和ChangeTracker发生更改时,我不会更改令牌:
public override int SaveChanges(bool acceptAllChangesOnSuccess)
{
if (SettingChanged() == true)
{
}
return base.SaveChanges(acceptAllChangesOnSuccess);
}
和我的DbChangeToken calss:
public class DbChangeToken : IChangeToken
{
private DateTime _lastModified;
private DateTime _lastRequested;
public bool HasChanged
{
get
{
var result = _lastModified >= _lastRequested;
_lastRequested = DateTime.Now;
return result;
}
}
public bool ActiveChangeCallbacks => true;
public IDisposable RegisterChangeCallback(Action<object> callback, object state) => EmptyDisposable.Instance;
}
我的目标是每次调用SaveChange Method时更改_lastModified。