Пример #1
0
        public Maybe <bool, Exception[]> BulkInsert(string tableName, DataTable dataTable, string connectionString)
        {
            var maybe = new Maybe <bool, Exception[]>();

            try
            {
                StructuredQueryLanguage.BulkInsert(tableName, dataTable, connectionString);
                maybe = maybe.With(true);
            }
            catch (Exception ex)
            {
                maybe.With(new Exception[] { ex });
            }

            return(maybe);
        }
Пример #2
0
        public Maybe <T, Exception[]> ExecuteReader <T>(Func <IDataReader, T> reader, string usp, string connectionString, params SqlParameter[] parameters)
        {
            var maybe = new Maybe <T, Exception[]>();

            try
            {
                var result = StructuredQueryLanguage.ExecuteReader(reader, usp, connectionString, parameters);
                maybe = maybe.With(result);
            }
            catch (Exception ex)
            {
                maybe.With(new Exception[] { ex });
            }

            return(maybe);
        }
Пример #3
0
        public Maybe <int, Exception[]> ExecuteNonQuery(string usp, string connectionString, params SqlParameter[] parameters)
        {
            var maybe = new Maybe <int, Exception[]>();

            try
            {
                var result = StructuredQueryLanguage.ExecuteNonQuery(usp, connectionString, parameters);
                maybe = maybe.With(result);
            }
            catch (Exception ex)
            {
                maybe.With(new Exception[] { ex });
            }

            return(maybe);
        }
        public Response BulkInsert(string tableName, DataTable dataTable, string connectionString)
        {
            var response = new Response();

            try
            {
                StructuredQueryLanguage.BulkInsert(tableName, dataTable, connectionString);
                response = response.AsValid();
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error calling {tableName}: {ex}");
            }

            return(response);
        }
        public Response <int> ExecuteNonQuery(string usp, string connectionString, params SqlParameter[] parameters)
        {
            var response = new Response <int>();

            try
            {
                var result = StructuredQueryLanguage.ExecuteNonQuery(usp, connectionString, parameters);
                response = response.With(result);
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error calling {usp}: {ex}");
            }

            return(response);
        }
        public Response <T> ExecuteReader <T>(Func <IDataReader, T> reader, string usp, string connectionString, params SqlParameter[] parameters)
        {
            var response = new Response <T>();

            try
            {
                var result = StructuredQueryLanguage.ExecuteReader(reader, usp, connectionString, parameters);
                response = response.With(result);
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error calling {usp} for type {typeof(T).FullName}: {ex}");
            }

            return(response);
        }
Пример #7
0
        public async Task <Maybe <T, Exception[]> > ExecuteReaderAsync <T>(Func <IDataReader, T> reader, string usp, string connectionString, params SqlParameter[] parameters)
        {
            var maybe = new Maybe <T, Exception[]>();

            try
            {
                var result = await StructuredQueryLanguage.ExecuteReaderAsync(reader, usp, connectionString, parameters);

                maybe = maybe.With(result);
            }
            catch (AggregateException ae)
            {
                maybe = maybe.With(ae.Flatten().InnerExceptions.ToArray());
            }
            catch (Exception ex)
            {
                maybe.With(new Exception[] { ex });
            }

            return(maybe);
        }
Пример #8
0
        public async Task <Maybe <bool, Exception[]> > BulkInsertAsync(string tableName, DataTable dataTable, string connectionString)
        {
            var maybe = new Maybe <bool, Exception[]>();

            try
            {
                await StructuredQueryLanguage.BulkInsertAsync(tableName, dataTable, connectionString);

                maybe = maybe.With(true);
            }
            catch (AggregateException ae)
            {
                maybe = maybe.With(ae.Flatten().InnerExceptions.ToArray());
            }
            catch (Exception ex)
            {
                maybe.With(new Exception[] { ex });
            }

            return(maybe);
        }
        public async Task <Response <T> > ExecuteReaderAsync <T>(Func <IDataReader, T> reader, string usp, string connectionString, params SqlParameter[] parameters)
        {
            var response = new Response <T>();

            try
            {
                var result = await StructuredQueryLanguage.ExecuteReaderAsync(reader, usp, connectionString, parameters);

                response = response.With(result);
            }
            catch (AggregateException ae)
            {
                foreach (var e in ae.Flatten().InnerExceptions)
                {
                    e.LogValue($"Aggregate error calling {usp} for type {typeof(T).FullName}: {e}");
                }
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error calling {usp} for type {typeof(T).FullName}: {ex}");
            }

            return(response);
        }
        public async Task <Response> BulkInsertAsync(string tableName, DataTable dataTable, string connectionString)
        {
            var response = new Response();

            try
            {
                await StructuredQueryLanguage.BulkInsertAsync(tableName, dataTable, connectionString);

                response = response.AsValid();
            }
            catch (AggregateException ae)
            {
                foreach (var e in ae.Flatten().InnerExceptions)
                {
                    e.LogValue($"Aggregate error calling {tableName}: {e}");
                }
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error calling {tableName}: {ex}");
            }

            return(response);
        }
        public async Task <Response <int> > ExecuteNonQueryAsync(string usp, string connectionString, params SqlParameter[] parameters)
        {
            var response = new Response <int>();

            try
            {
                var result = await StructuredQueryLanguage.ExecuteNonQueryAsync(usp, connectionString, parameters);

                response = response.With(result);
            }
            catch (AggregateException ae)
            {
                foreach (var e in ae.Flatten().InnerExceptions)
                {
                    e.LogValue($"Aggregate error calling {usp}: {e}");
                }
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error calling {usp}: {ex}");
            }

            return(response);
        }
Пример #12
0
 public static Task BulkInsertAsync(string tableName, DataTable dataTable, string connectionString)
 {
     return(StructuredQueryLanguage.BulkInsertAsync(tableName, dataTable, connectionString));
 }
Пример #13
0
 public static Task <int> ExecuteNonQueryAsync(string usp, string connectionString, params SqlParameter[] parameters)
 {
     return(StructuredQueryLanguage.ExecuteNonQueryAsync(usp, connectionString, parameters));
 }
Пример #14
0
 public static Task <T> ExecuteReaderAsync <T>(Func <IDataReader, T> reader, string usp, string connectionString, params SqlParameter[] parameters)
 {
     return(StructuredQueryLanguage.ExecuteReaderAsync(reader, usp, connectionString, parameters));
 }
Пример #15
0
 public static void BulkInsert(string tableName, DataTable dataTable, string connectionString)
 {
     StructuredQueryLanguage.BulkInsert(tableName, dataTable, connectionString);
 }