public IBoilerStatus Retrieve() { using (var db = new BoilerDbContext()) { var b = db.Set<BoilerStatus>().OrderByDescending(t => t.Id).FirstOrDefault(); return b == null ? new BoilerStatus() : b; } }
public Startup(IHostingEnvironment env, IApplicationEnvironment app) { _app = app; using (var db = new BoilerDbContext()) { db.Database.EnsureCreated(); } }
public IBoilerStatus Save(IBoilerStatus boiler) { using (var db = new BoilerDbContext()) { var b = db.Set<BoilerStatus>().OrderByDescending(t => t.Id).Select(i => i.Id).FirstOrDefault(); db.Boiler.RemoveRange(db.Boiler.Where(w => w.Id < b - 1000000)); db.Boiler.Add((BoilerStatus)boiler); db.SaveChanges(); } return boiler; }