コード例 #1
0
 /// <summary>
 /// Asynchronously execute a stored procedure.
 /// </summary>
 /// <param name="storedproc">The stored procedure.</param>
 /// <param name="parameterModifier">The parameter modifier.</param>
 /// <param name="reader1">The reader 1.</param>
 /// <typeparam name="T1">The type which the first reader produces.</typeparam>
 /// <returns>The <see cref="Task"/>.</returns>
 public Task <IEnumerable <T1> > ExecuteAsync <T1>(
     string storedproc,
     Action <SqlParameterCollection> parameterModifier,
     Func <SqlDataReader, T1> reader1) where T1 : class
 {
     return
         (this.ExecuteAsync(storedproc, parameterModifier, new Func <SqlDataReader, object>[] { reader1 })
          .ContinueWith(
              task =>
     {
         return SqlClientFacade.ExecuteContinuation(
             task,
             result => result.First().Cast <T1>());
     }));
 }
コード例 #2
0
        /// <summary>
        /// Execute a non query.
        /// </summary>
        /// <param name="storedProc">The stored procedure.</param>
        /// <param name="parameterModifier">The parameter modifier.</param>
        /// <returns>An async task.</returns>
        public async Task ExecuteAsync(string storedProc, Action <SqlParameterCollection> parameterModifier)
        {
            using (var connection = await this.GetConnection())
            {
                var command = SqlClientFacade.InitializeCall(storedProc, parameterModifier, connection);
                await command.ExecuteNonQueryAsync(this.tokenSource.Token).ContinueWith(
                    queryResult =>
                {
                    if (queryResult.IsFaulted)
                    {
                        throw queryResult.Exception.InnerException;
                    }

                    SqlClientFacade.VerifyResults(command.Parameters);

                    if (queryResult.IsCanceled)
                    {
                        throw new CancellationException("Query was canelled.");
                    }
                });
            }
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlDataLayer"/> class.
 /// </summary>
 /// <param name="connectionString">The connection string.</param>
 internal SqlDataLayer(string connectionString)
 {
     this.sqlClient = new SqlClientFacade(connectionString);
 }