Пример #1
0
        public static void AddOrCreateEntity <T>(this EStoreEntities db, T entity) where T : class, IdEntity
        {
            var entityState = entity.Id == 0 ? EntityState.Added : EntityState.Modified;

            db.Entry(entity).State = entityState;
            db.SaveChanges();
        }
Пример #2
0
 public static void Save <T>(this EStoreEntities db, T entity) where T : class, IdEntity
 {
     db.Set <T>().Attach(entity);
     db.Entry(entity).State = entity.Id == 0 ? EntityState.Added : EntityState.Modified;
     db.SaveChanges();
 }