コード例 #1
0
 public Batch Create(Source source)
 {
     Batch batch;
     using (var dbContext = new TimberMillDbContext())
     {
         batch = new Batch {Source = source};
         dbContext.Batchs.Add(batch);
         dbContext.Entry(batch.Source).State = EntityState.Unchanged;
         dbContext.SaveChanges();
     }
     return batch;
 }
コード例 #2
0
        public void Save(LogEvent logEvent)
        {
            using (var dbContext = new TimberMillDbContext())
            {
                dbContext.Batchs.Attach(logEvent.Batch);
                dbContext.Sources.Attach(logEvent.Batch.Source);

                dbContext.LogEvents.Add(logEvent);
                //dbContext.Entry(logEvent.Batch).State = EntityState.Unchanged;
                //dbContext.Entry(logEvent.Batch.Source).State = EntityState.Unchanged;
                dbContext.SaveChanges();
            }
        }
コード例 #3
0
        public void Save(LogEvent logEvent)
        {
            using (var dbContext = new TimberMillDbContext())
            {
                dbContext.Batchs.Attach(logEvent.Batch);
                dbContext.Sources.Attach(logEvent.Batch.Source);

                dbContext.LogEvents.Add(logEvent);
                //dbContext.Entry(logEvent.Batch).State = EntityState.Unchanged;
                //dbContext.Entry(logEvent.Batch.Source).State = EntityState.Unchanged;
                dbContext.SaveChanges();
            }
        }
コード例 #4
0
        public Batch Create(Source source)
        {
            Batch batch;

            using (var dbContext = new TimberMillDbContext())
            {
                batch = new Batch {
                    Source = source
                };
                dbContext.Batchs.Add(batch);
                dbContext.Entry(batch.Source).State = EntityState.Unchanged;
                dbContext.SaveChanges();
            }
            return(batch);
        }
コード例 #5
0
        public Source GetOrCreate(string name, string category)
        {
            using (var dbContext = new TimberMillDbContext())
            {
                var source = Get(dbContext, name, category);

                if (source == null)
                {
                    source = new Source {Name = name, Category = category};
                    dbContext.Sources.Add(source);
                    dbContext.SaveChanges();
                }
                return source;
            }
        }
コード例 #6
0
        public Source GetOrCreate(string name, string category)
        {
            using (var dbContext = new TimberMillDbContext())
            {
                var source = Get(dbContext, name, category);

                if (source == null)
                {
                    source = new Source {
                        Name = name, Category = category
                    };
                    dbContext.Sources.Add(source);
                    dbContext.SaveChanges();
                }
                return(source);
            }
        }