Browse Source

aspnetcore: ef-pg batch update (#4946)

* aspcore: add platform multiple queries

* Add missing console output

* tweak postgresql connectionstring

* aspcore: ef batch update
n-stefan 6 years ago
parent
commit
3e9b0432f2
1 changed files with 1 additions and 11 deletions
  1. 1 11
      frameworks/CSharp/aspnetcore/Benchmarks/Data/EfDb.cs

+ 1 - 11
frameworks/CSharp/aspnetcore/Benchmarks/Data/EfDb.cs

@@ -16,13 +16,11 @@ namespace Benchmarks.Data
     {
     {
         private readonly IRandom _random;
         private readonly IRandom _random;
         private readonly ApplicationDbContext _dbContext;
         private readonly ApplicationDbContext _dbContext;
-        private readonly bool _useBatchUpdate;
 
 
         public EfDb(IRandom random, ApplicationDbContext dbContext, IOptions<AppSettings> appSettings)
         public EfDb(IRandom random, ApplicationDbContext dbContext, IOptions<AppSettings> appSettings)
         {
         {
             _random = random;
             _random = random;
             _dbContext = dbContext;
             _dbContext = dbContext;
-            _useBatchUpdate = appSettings.Value.Database != DatabaseServer.PostgreSql;
         }
         }
 
 
         private static readonly Func<ApplicationDbContext, int, Task<World>> _firstWorldQuery
         private static readonly Func<ApplicationDbContext, int, Task<World>> _firstWorldQuery
@@ -66,17 +64,9 @@ namespace Benchmarks.Data
                 _dbContext.Entry(result).Property("RandomNumber").CurrentValue = _random.Next(1, 10001);
                 _dbContext.Entry(result).Property("RandomNumber").CurrentValue = _random.Next(1, 10001);
 
 
                 results[i] = result;
                 results[i] = result;
-
-                if (!_useBatchUpdate)
-                {
-                    await _dbContext.SaveChangesAsync();
-                }
             }
             }
 
 
-            if (_useBatchUpdate)
-            {
-                await _dbContext.SaveChangesAsync();
-            }
+            await _dbContext.SaveChangesAsync();
 
 
             return results;
             return results;
         }
         }