如何使用IChangeToken使令牌过期?

时间:2017-04-19 20:52:25

标签: c# asp.net-core-mvc

当调用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。

0 个答案:

没有答案