Ejemplo n.º 1
0
        /// <summary>
        /// Executes this database operation and returns the database operation result.
        /// </summary>
        /// <returns>The database operation result.</returns>
        internal async Task <CDataBaseOperationResult> Run()
        {
            CDataBaseOperationResult p_result = new CDataBaseOperationResult();

            for (Int32 i = 0; i < _m_p_operation_queries.Count; ++i)
            {
                SOperationQuery operation_query             = _m_p_operation_queries[i];
                Queries.CDataBaseQueryResult p_query_result = await operation_query.m_p_query.RunAsync();

                if (operation_query.m_include_in_result)
                {
                    p_result.AddQueryResult(p_query_result);
                }

                if (operation_query.m_p_finished_handler != null)
                {
                    // problem: the finished handler is recursive: => include_in_result applies to all nested queries as well
                    Queries.CDataBaseQueryResult[] p_additional_results = await operation_query.m_p_finished_handler(this, p_result, p_query_result);

                    if (operation_query.m_include_in_result)
                    {
                        p_result.AddQueryResults(p_additional_results);
                    }
                }
            }
            return(p_result);
        }
Ejemplo n.º 2
0
        protected override CDataBaseQueryResult RunAsCommand(DbCommand p_command)
        {
            DbDataReader p_reader = null;

            try
            {
                p_reader = p_command.ExecuteReader();

                CDataBaseQueryResult p_result = new CDataBaseQueryResult(this);
                p_result.RetrieveFromReader(p_reader);

                p_reader.Close();

                return(p_result);
            }
            catch (MySqlException p_except)
            {
                return(new CDataBaseQueryResult(this, p_except));
            }
            catch (Exception p_except)
            {
                throw p_except;
            }
            finally
            {
                if (p_reader != null)
                {
                    p_reader.Close();
                }
            }
        }
Ejemplo n.º 3
0
        protected override async Task <CDataBaseQueryResult> RunAsCommandAsync(DbCommand p_command)
        {
            CDataBaseQueryResult p_result = new CDataBaseQueryResult(
                this,
                await p_command.ExecuteNonQueryAsync()
                );

            return(p_result);
        }
Ejemplo n.º 4
0
        protected override CDataBaseQueryResult RunAsCommand(DbCommand p_command)
        {
            CDataBaseQueryResult p_result = new CDataBaseQueryResult(
                this,
                p_command.ExecuteNonQuery()
                );

            return(p_result);
        }
Ejemplo n.º 5
0
        protected override async Task <CDataBaseQueryResult> RunAsCommandAsync(DbCommand p_command)
        {
            try
            {
                Int32 n_affected_rows = await p_command.ExecuteNonQueryAsync();

                CDataBaseQueryResult p_result = new CDataBaseQueryResult(this, n_affected_rows);
                return(p_result);
            }
            catch (Exception p_except)
            {
                throw p_except;
            }
        }
Ejemplo n.º 6
0
        protected override CDataBaseQueryResult RunAsCommand(DbCommand p_command)
        {
            try
            {
                Int32 n_affected_rows = p_command.ExecuteNonQuery();

                CDataBaseQueryResult p_result = new CDataBaseQueryResult(this, n_affected_rows);
                return(p_result);
            }
            catch (Exception p_except)
            {
                throw p_except;
            }
        }
Ejemplo n.º 7
0
        public CDataBaseResultSet ExecuteReader(String p_query)
        {
            using (DbConnection p_connection = GetConnection())
            {
                using (DbCommand p_command = p_connection.CreateCommand())
                {
                    p_command.CommandText = p_query;

                    RaiseCommandExecuted(this, p_command);

                    Queries.CDataBaseQueryResult p_result = new Queries.CDataBaseQueryResult(null);
                    p_result.RetrieveFromReader(p_command.ExecuteReader());
                    return(p_result.m_p_result_set);
                }
            }
        }
Ejemplo n.º 8
0
        public async Task <CDataBaseResultSet> ExecuteReaderAsync(String p_query)
        {
            using (DbConnection p_connection = (await GetConnectionAsync()))
            {
                using (DbCommand p_command = p_connection.CreateCommand())
                {
                    p_command.CommandText = p_query;

                    RaiseCommandExecuted(this, p_command);

                    Queries.CDataBaseQueryResult p_result = new Queries.CDataBaseQueryResult(null);
                    await p_result.RetrieveFromReaderAsync(await p_command.ExecuteReaderAsync());

                    return(p_result.m_p_result_set);
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds a new database query result to the database operation result.
 /// </summary>
 /// <param name="p_result">The query result to add to the database operation result.</param>
 internal void AddQueryResult(Queries.CDataBaseQueryResult p_result)
 {
     _m_p_results.Add(p_result);
 }