예제 #1
0
파일: BaseRepository.cs 프로젝트: cx525v/WP
 // use for buffered queries that do not return a type
 async Task IDatabaseConnectionFactory.GetConnection(Func <IDbConnection, Task> getData)
 {
     try
     {
         using (var connection = new CisCustomDbConnection(new SqlConnection(_connectionString), this._commandTimeout))
         {
             await connection.OpenAsync();
             await getData(connection);
         }
     }
     catch (TimeoutException ex)
     {
         throw new Exception(String.Format("{0}.GetConnection() experienced a SQL timeout", GetType().FullName), ex);
     }
     catch (SqlException ex)
     {
         throw new Exception(String.Format("{0}.GetConnection() experienced a SQL exception (not a timeout)", GetType().FullName), ex);
     }
 }
예제 #2
0
파일: BaseRepository.cs 프로젝트: cx525v/WP
        // use for non-buffered queries that return a type
        async Task <TResult> IDatabaseConnectionFactory.GetConnection <TRead, TResult>(Func <IDbConnection, Task <TRead> > getData, Func <TRead, Task <TResult> > process)
        {
            try
            {
                using (var connection = new CisCustomDbConnection(new SqlConnection(_connectionString), this._commandTimeout))
                {
                    await connection.OpenAsync();

                    var data = await getData(connection);

                    return(await process(data));
                }
            }
            catch (TimeoutException ex)
            {
                throw new Exception(String.Format("{0}.GetConnection() experienced a SQL timeout", GetType().FullName), ex);
            }
            catch (SqlException ex)
            {
                throw new Exception(String.Format("{0}.GetConnection() experienced a SQL exception (not a timeout)", GetType().FullName), ex);
            }
        }