fix nullable warnings AsbCloudDbContext

This commit is contained in:
Фролов 2022-07-04 17:33:32 +05:00
parent 12ff470d5f
commit 5f6dae1ea6
2 changed files with 7 additions and 6 deletions

View File

@ -345,14 +345,15 @@ namespace AsbCloudDb.Model
FillData(modelBuilder); FillData(modelBuilder);
} }
public Task<int> RefreshMaterializedViewAsync<TEntity>(CancellationToken token = default) public Task<int> RefreshMaterializedViewAsync<TEntity>(CancellationToken token)
where TEntity : class where TEntity : class
{ {
var materializedViewName = Set<TEntity>().EntityType.GetViewName(); var materializedViewName = Set<TEntity>().EntityType.GetViewName()
return RefreshMaterializedViewAsync(materializedViewName!, token); ?? throw new System.Exception($"RefreshMaterializedViewAsync<{typeof(TEntity).Name}>(..) db table for this type does not found.");
return RefreshMaterializedViewAsync(materializedViewName, token);
} }
public Task<int> RefreshMaterializedViewAsync(string materializedViewName, CancellationToken token = default) public Task<int> RefreshMaterializedViewAsync(string materializedViewName, CancellationToken token)
{ {
var sql = $"REFRESH MATERIALIZED VIEW {materializedViewName};"; var sql = $"REFRESH MATERIALIZED VIEW {materializedViewName};";
return Database.ExecuteSqlRawAsync(sql, token); return Database.ExecuteSqlRawAsync(sql, token);

View File

@ -56,8 +56,8 @@ namespace AsbCloudDb.Model
DatabaseFacade Database { get; } DatabaseFacade Database { get; }
Task<int> RefreshMaterializedViewAsync(string? mwName = null, CancellationToken token = default); Task<int> RefreshMaterializedViewAsync(string mwName, CancellationToken token);
Task<int> RefreshMaterializedViewAsync<TEntity>(CancellationToken token = default) where TEntity : class; Task<int> RefreshMaterializedViewAsync<TEntity>(CancellationToken token) where TEntity : class;
int SaveChanges(); int SaveChanges();
int SaveChanges(bool acceptAllChangesOnSuccess); int SaveChanges(bool acceptAllChangesOnSuccess);
Task<int> SaveChangesAsync(CancellationToken cancellationToken); Task<int> SaveChangesAsync(CancellationToken cancellationToken);