split RefreshMaterializedViewAsync to 2 overload

This commit is contained in:
ngfrolov 2022-05-11 09:04:32 +05:00
parent 8b6a9c78c7
commit 09b39c14ea

View File

@ -286,17 +286,16 @@ namespace AsbCloudDb.Model
FillData(modelBuilder);
}
public Task<int> RefreshMaterializedViewAsync<TEntity>(string? mwName = null, CancellationToken token = default)
public Task<int> RefreshMaterializedViewAsync<TEntity>(CancellationToken token = default)
where TEntity : class
{
var materializedView = string.IsNullOrEmpty(mwName)
? Set<TEntity>().EntityType.GetViewName()
: mwName;
var materializedViewName = Set<TEntity>().EntityType.GetViewName();
return RefreshMaterializedViewAsync(materializedViewName!, token);
}
if (string.IsNullOrEmpty(materializedView))
return Task.FromResult(0);
var sql = $"REFRESH MATERIALIZED VIEW {materializedView};";
public Task<int> RefreshMaterializedViewAsync(string materializedViewName, CancellationToken token = default)
{
var sql = $"REFRESH MATERIALIZED VIEW {materializedViewName};";
return Database.ExecuteSqlRawAsync(sql, token);
}