Example #1
0
 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;
     }));
 }
Example #2
0
 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;
     }));
 }