예제 #1
0
        /// <summary>
        ///  Performs CRUD execution of queries that do not return result set. Override to do custom Query interpretation
        /// </summary>
        protected internal virtual int DoExecuteWithoutFetch(MySqlConnection cnn, MySqlTransaction transaction, Query[] queries)
        {
            if (queries == null)
            {
                return(0);
            }

            var affected = 0;

            foreach (var query in queries)
            {
                var handler = QueryResolver.Resolve(query);
                try
                {
                    affected += handler.ExecuteWithoutFetch(new MySQLCRUDQueryExecutionContext(this, cnn, transaction), query);
                }
                catch (Exception error)
                {
                    throw new MySQLDataAccessException(
                              StringConsts.EXECUTE_WITHOUT_FETCH_ERROR + error.ToMessageWithType(),
                              error,
                              KeyViolationKind.Unspecified,
                              CRUDGenerator.KeyViolationName(error));
                }
            }

            return(affected);
        }
예제 #2
0
        /// <summary>
        ///  Performs CRUD load. Override to do custom Query interpretation
        /// </summary>
        protected internal virtual List <RowsetBase> DoLoad(MySqlConnection cnn, MySqlTransaction transaction, Query[] queries, bool oneRow = false)
        {
            var result = new List <RowsetBase>();

            if (queries == null)
            {
                return(result);
            }

            foreach (var query in queries)
            {
                var handler = QueryResolver.Resolve(query);
                try
                {
                    var rowset = handler.Execute(new MySQLCRUDQueryExecutionContext(this, cnn, transaction), query, oneRow);
                    result.Add(rowset);
                }
                catch (Exception error)
                {
                    throw new MySQLDataAccessException(
                              StringConsts.LOAD_ERROR + error.ToMessageWithType(),
                              error,
                              KeyViolationKind.Unspecified,
                              CRUDGenerator.KeyViolationName(error));
                }
            }

            return(result);
        }
예제 #3
0
        /// <summary>
        ///  Performs CRUD load. Override to do custom Query interpretation
        /// </summary>
        protected internal virtual Cursor DoOpenCursor(MySqlConnection cnn, MySqlTransaction transaction, Query query)
        {
            var context = new MySQLCRUDQueryExecutionContext(this, cnn, transaction);
            var handler = QueryResolver.Resolve(query);

            try
            {
                return(handler.OpenCursor(context, query));
            }
            catch (Exception error)
            {
                throw new MySQLDataAccessException(
                          StringConsts.OPEN_CURSOR_ERROR + error.ToMessageWithType(),
                          error,
                          KeyViolationKind.Unspecified,
                          CRUDGenerator.KeyViolationName(error));
            }
        }
예제 #4
0
        /// <summary>
        ///  Performs CRUD load without fetching data only returning schema. Override to do custom Query interpretation
        /// </summary>
        protected internal virtual Schema DoGetSchema(MySqlConnection cnn, MySqlTransaction transaction, Query query)
        {
            if (query == null)
            {
                return(null);
            }

            var handler = QueryResolver.Resolve(query);

            try
            {
                return(handler.GetSchema(new MySQLCRUDQueryExecutionContext(this, cnn, transaction), query));
            }
            catch (Exception error)
            {
                throw new MySQLDataAccessException(
                          StringConsts.GET_SCHEMA_ERROR + error.ToMessageWithType(),
                          error,
                          KeyViolationKind.Unspecified,
                          CRUDGenerator.KeyViolationName(error));
            }
        }