예제 #1
0
        public virtual void Update(T entity)
        {
            IDbEntityEntryContext entry = _objectContext.GetEntry(entity);

            if (entry.IsState(EntityState.Detached))
            {
                _objectSet.Attach(entity);
            }
            else
            {
                entry.SetState(EntityState.Modified);
            }
        }
예제 #2
0
        public virtual void Add(T entity)
        {
            IDbEntityEntryContext entry = _objectContext.GetEntry(entity);

            if (entry.IsState(EntityState.Detached))
            {
                _objectSet.Add(entity);
            }
            else
            {
                entry.SetState(EntityState.Added);
            }
        }
예제 #3
0
        public virtual void Remove(T entity)
        {
            IDbEntityEntryContext entry = _objectContext.GetEntry(entity);

            if (entry.IsState(EntityState.Detached))
            {
                _objectSet.Attach(entity);
            }
            else
            {
                entry.SetState(EntityState.Deleted);
            }
            _objectSet.Remove(entity);
        }