Task <ConnectionWrapper> GetConnection(ITransactionContext context) { return(context .GetOrAdd(CurrentConnectionKey, async() => { var dbConnection = await _connectionHelper.GetConnection(); var connectionWrapper = new ConnectionWrapper(dbConnection); context.OnCommitted(() => { dbConnection.Complete(); return Task.FromResult(0); }); context.OnDisposed(() => connectionWrapper.Dispose()); return connectionWrapper; })); }
ConnectionWrapper GetConnection(ITransactionContext context) { return(context .GetOrAdd(CurrentConnectionKey, () => { var dbConnection = _connectionHelper.GetConnection(); var connectionWrapper = new ConnectionWrapper(dbConnection); context.OnCommitted(() => { dbConnection.Complete(); return Task.CompletedTask; }); context.OnDisposed(() => connectionWrapper.Dispose()); return connectionWrapper; })); }