Skip to content

Commit

Permalink
Add async support for loading column sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorFedchenko committed Feb 9, 2021
1 parent e2507c8 commit 6df501b
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ private async Task<BatchComplete> ExecuteChunk(RequestChunk chunk, IActorContext
await connection.OpenAsync();

// pre-load column sizes to use in queries
LoadColumnSizes(connection, Setup.NamingConventions);
await LoadColumnSizes(connection);

using (var tx = connection.BeginTransaction(Setup.IsolationLevel))
using (var command = (TCommand)connection.CreateCommand())
Expand Down Expand Up @@ -1414,22 +1414,21 @@ protected void AddParameter(TCommand command, string paramName, DbType dbType, o
/// </para>
///
/// </summary>
/// <param name="connection"></param>
/// <param name="conventions"></param>
protected virtual ColumnSizesInfo LoadColumnSizesInternal(DbConnection connection, QueryConfiguration conventions)
/// <param name="connection">Already opened connection to the database</param>
protected virtual Task<ColumnSizesInfo> LoadColumnSizesInternal(DbConnection connection)
{
return ColumnSizesInfo.Default;
return Task.FromResult(ColumnSizesInfo.Default);
}

private void LoadColumnSizes(DbConnection connection, QueryConfiguration conventions)
private async Task LoadColumnSizes(DbConnection connection)
{
// load schema/initialize column sizes only once
if (ColumnSizes != null)
return;

try
{
ColumnSizes = LoadColumnSizesInternal(connection, conventions);
ColumnSizes = await LoadColumnSizesInternal(connection);
}
catch (Exception exception)
{
Expand Down

0 comments on commit 6df501b

Please sign in to comment.