コード例 #1
0
        public void Update(TEntity entity)
        {
            _context.Set <TEntity>().Attach(entity);

            IDbEntityEntry entry = _context.Entry <TEntity>(entity);

            entry.State = EntityState.Modified;
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
 /// <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)
 {
 }
コード例 #4
0
ファイル: InvokeSetup.cs プロジェクト: mtranter/EntityHooks
        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");
            }
        }