public async Task <IActionResult> PublishWithTranscation() { using (var trans = _pgDbContext.Database.BeginTransaction(_capPublisher, true)) { try { var apiConfig = new ApiConfig { ApiName = "111122", ApiDesc = "223", ReturnType = "1", ReturnExpect = "1", IsAsync = true, OperCode = "999", OperTime = DateTime.Now }; await _pgDbContext.ApiConfig.AddAsync(apiConfig); await _pgDbContext.SaveChangesAsync(); _capPublisher.Publish("sample.rabbitmq.demo.transcation", apiConfig); trans.Commit(); } catch (Exception ex) { trans.Rollback(); } return(Ok()); } }
public async Task <int> PgComplete() { return(await _pgContext.SaveChangesAsync()); }
public async Task AddRangeAsync(IEnumerable <UserRole> userRoles) { dbContext.AddRange(userRoles); await dbContext.SaveChangesAsync().ConfigureAwait(false); }
public async Task AddRangeAsync(IEnumerable <RolePermission> rolePermissions) { dbContext.AddRange(rolePermissions); await dbContext.SaveChangesAsync().ConfigureAwait(false); }
public async Task SaveAsync() { await _context.SaveChangesAsync(); }
public async Task <int> SaveChanges() { return(await Db.SaveChangesAsync()); }