public DownloadTask DownloadTask(string gid) { using (var context = new Model.DbContext()) { return(context.DownloadTasks.Find(gid)); } }
public HomeController(UserManager <User> userManager, RoleManager <Role> roleManager, Model.DbContext dbContext, SignInManager <User> signInManager) { _signInManager = signInManager; _dbContext = dbContext; _roleManager = roleManager; _userManager = userManager; }
public async Task DeleteAsync <T>(T entity) where T : class { using (var context = new Model.DbContext()) { context.Entry <T>(entity).State = EntityState.Deleted; await context.SaveChangesAsync(); } }
public async Task UpdateAsync <T>(T oriItem, T newItem) where T : class { using (var context = new Model.DbContext()) { context.Entry <T>(oriItem).State = EntityState.Detached; context.Entry <T>(newItem).State = EntityState.Modified; await context.SaveChangesAsync(); } }
public Common() { this.DbContext = System.Runtime.Remoting.Messaging.CallContext.GetData(Azeroth.Common.Flags.DbContext) as Model.DbContext; if (this.DbContext == null) { this.DbContext = new Model.DbContext(); System.Runtime.Remoting.Messaging.CallContext.SetData(Azeroth.Common.Flags.DbContext, this.DbContext); } }
protected void DbInit() { using (var context = new Model.DbContext()) { if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } } }
public void Add <T>(T entity) where T : class { if (entity == null) { return; } using (var context = new Model.DbContext()) { context.Set <T>().Add(entity); context.SaveChanges(); } }