public void Update(TEntity entity) { _context.Set <TEntity>().Attach(entity); IDbEntityEntry entry = _context.Entry <TEntity>(entity); entry.State = EntityState.Modified; }
/// <summary> /// Hooks the entity entry. /// </summary> /// <param name="entry">The entity entry.</param> public void HookEntry(IDbEntityEntry entry) { var entity = entry.Entity as TEntity; if (entity != null && (_hookEntityState & entry.State) != 0) { _hookAction(entity); } }
/// <summary> /// Initializes a new instance of the <see cref="EntityEntryFreezedAdapter"/> class. /// </summary> /// <param name="entry">The entry.</param> public EntityEntryFreezedAdapter(IDbEntityEntry entry) : base(entry.Entity, entry.State) { }
protected void ActAndAssert <T>(IInvokeSetup <T> setup, ref IDbHook registeredHook, IDbEntityEntry dbEntityEntry, bool shouldInvokeHook) where T : class { setup.Do( s => { if (shouldInvokeHook) { Assert.Pass("Hook invoked"); } else { Assert.Fail("Hook invoked"); } }); Assert.That(registeredHook, Is.Not.Null, "Hook not registered"); registeredHook.HookEntry(dbEntityEntry); if (!shouldInvokeHook) { Assert.Pass("Hook not invoked"); } else { Assert.Fail("Hook not invoked"); } }