Example #1
0
        private T ExecuteScalar <T>(
            IAdoProcedure procedure,
            ICommand command,
            SQLiteConnection connection,
            SQLiteTransaction transaction)
        {
            var context = CreateContext(command, connection, transaction, null, null, null);

            try
            {
                using (var dataReader = procedure.Execute(context))
                {
                    if (dataReader == null)
                    {
                        return(default(T));
                    }
                    if (!dataReader.Read())
                    {
                        return(default(T));
                    }
                    return(dataReader.Get <T>(0));
                }
            }
            catch (Exception e)
            {
                throw new AdoProcedureException(command, connection, e, "ExecuteScalar<" + typeof(T).Name + ">");
            }
        }
Example #2
0
        private long ExecuteNonQuery(
            IAdoProcedure procedure,
            ICommand command,
            int timeoutSeconds,
            SQLiteConnection connection,
            SQLiteTransaction transaction)
        {
            var tokenSource = new CancellationTokenSource();
            var task        = Task <long> .Factory.StartNew(() => ExecuteNonQuery(procedure, command, connection, transaction), tokenSource.Token);

            return(WaitForProcedureCompletion(command, timeoutSeconds, connection, task, tokenSource, "ExecuteNonQuery"));
        }
Example #3
0
        private T ExecuteScalar <T>(
            IAdoProcedure procedure,
            ICommand command,
            int timeoutSeconds,
            SQLiteConnection connection,
            SQLiteTransaction transaction)
        {
            var tokenSource = new CancellationTokenSource();
            var task        = Task <T> .Factory.StartNew(() => ExecuteScalar <T>(procedure, command, connection, transaction), tokenSource.Token);

            return(WaitForProcedureCompletion(command, timeoutSeconds, connection, task, tokenSource, "ExecuteScalar<" + typeof(T).Name + ">"));
        }
Example #4
0
        private IDataReader ExecuteReader(
            IAdoProcedure procedure,
            ICommand command,
            int timeoutSeconds,
            SQLiteConnection connection,
            SQLiteTransaction transaction,
            string dataShapeName,
            Action <IDataReader> closeAction,
            Action <IDataReader> errorAction)
        {
            var tokenSource = new CancellationTokenSource();
            var task        = Task <IDataReader> .Factory.StartNew(() => ExecuteReader(procedure, command, connection, transaction, dataShapeName, closeAction, errorAction), tokenSource.Token);

            return(WaitForProcedureCompletion(command, timeoutSeconds, connection, task, tokenSource, "ExecuteReader"));
        }
Example #5
0
        private long ExecuteNonQuery(
            IAdoProcedure procedure,
            ICommand command,
            SQLiteConnection connection,
            SQLiteTransaction transaction)
        {
            var context = CreateContext(command, connection, transaction, null, null, null);

            try
            {
                using (procedure.Execute(context))
                {
                    return(context.RowsAffected);
                }
            }
            catch (Exception e)
            {
                throw new AdoProcedureException(command, connection, e, "ExecuteNonQuery");
            }
        }
Example #6
0
        private IDataReader ExecuteReader(
            IAdoProcedure procedure,
            ICommand command,
            SQLiteConnection connection,
            SQLiteTransaction transaction,
            string dataShapeName,
            Action <IDataReader> closeAction,
            Action <IDataReader> errorAction)
        {
            var context = CreateContext(command, connection, transaction, dataShapeName, closeAction, errorAction);

            try
            {
                return(procedure.Execute(context));
            }
            catch (Exception e)
            {
                throw new AdoProcedureException(command, connection, e, "ExecuteReader");
            }
        }