Exemple #1
0
    public TransientOperationScope(IServiceProvider services)
    {
        var loggerFactory = services.GetService <ILoggerFactory>();

        Log       = loggerFactory?.CreateLogger(GetType()) ?? NullLogger.Instance;
        Services  = services;
        Clocks    = services.Clocks();
        AgentInfo = services.GetRequiredService <AgentInfo>();
        Operation = new TransientOperation(true)
        {
            AgentId   = AgentInfo.Id,
            StartTime = Clocks.SystemClock.Now,
        };
        CommandContext = services.GetRequiredService <CommandContext>();
    }
Exemple #2
0
 /// <summary>
 /// Core method for executing methods on the <see cref="DbCommand"/> object resolved from the virtual <see cref="ExecuteCommandCore"/> method.
 /// </summary>
 /// <typeparam name="T">The type to return.</typeparam>
 /// <param name="dataCommand">The data command to execute.</param>
 /// <param name="parameters">The parameters to use in the command.</param>
 /// <param name="commandInvoker">The function delegate that will invoke a method on the resolved <see cref="DbCommand"/> from the virtual <see cref="ExecuteCommandCore"/> method.</param>
 /// <returns>A value of <typeparamref name="T"/> that is equal to the invoked method of the <see cref="DbCommand"/> object.</returns>
 protected virtual T ExecuteCore <T>(IDataCommand dataCommand, DbParameter[] parameters, Func <DbCommand, T> commandInvoker)
 {
     return(TransientOperation.WithFunc(() => InvokeCommandCore(dataCommand, parameters, commandInvoker), TransientFaultHandlingOptionsCallback));
 }