Beispiel #1
0
        /// <summary>
        ///  Performs CRUD execution of queries that do not return result set. Override to do custom Query interpretation
        /// </summary>
        protected internal async virtual Task <int> DoExecuteWithoutFetchAsync(OracleConnection cnn, OracleTransaction transaction, Query[] queries)
        {
            if (queries == null)
            {
                return(0);
            }

            var affected = 0;

            foreach (var query in queries)
            {
                var handler = QueryResolver.Resolve(query);
                try
                {
                    affected += await handler.ExecuteWithoutFetchAsync(new OracleCRUDQueryExecutionContext(this, cnn, transaction), query).ConfigureAwait(false);
                }
                catch (Exception error)
                {
                    throw new OracleDataAccessException(
                              StringConsts.EXECUTE_WITHOUT_FETCH_ERROR + error.ToMessageWithType(),
                              error,
                              KeyViolationKind.Unspecified,
                              CRUDGenerator.KeyViolationName(error));
                }
            }

            return(affected);
        }
Beispiel #2
0
        /// <summary>
        ///  Performs CRUD load. Override to do custom Query interpretation
        /// </summary>
        protected internal async virtual Task <List <RowsetBase> > DoLoadAsync(OracleConnection cnn, OracleTransaction transaction, Query[] queries, bool oneDoc = false)
        {
            var result = new List <RowsetBase>();

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

            foreach (var query in queries)
            {
                var handler = QueryResolver.Resolve(query);
                try
                {
                    var rowset = await handler.ExecuteAsync(new OracleCRUDQueryExecutionContext(this, cnn, transaction), query, oneDoc).ConfigureAwait(false);

                    result.Add(rowset);
                }
                catch (Exception error)
                {
                    throw new OracleDataAccessException(
                              StringConsts.LOAD_ERROR + error.ToMessageWithType(),
                              error,
                              KeyViolationKind.Unspecified,
                              CRUDGenerator.KeyViolationName(error));
                }
            }

            return(result);
        }
        /// <summary>
        /// Populates OracleCommand with parameters from CRUD Query object
        /// Note: this code was purposely made provider specific because other providers may treat some nuances differently
        /// </summary>
        public void PopulateParameters(OracleCommand cmd, Query query)
        {
            foreach (var par in query.Where(p => p.HasValue))
            {
                cmd.Parameters.Add(par.Name, par.Value);
            }

            if (query.StoreKey != null)
            {
                var where        = GeneratorUtils.KeyToWhere(query.StoreKey, cmd.Parameters);
                cmd.CommandText += "\n WHERE \n {0}".Args(where);
            }

            CRUDGenerator.ConvertParameters(Store, cmd.Parameters);
        }
Beispiel #4
0
        /// <summary>
        ///  Performs CRUD load. Override to do custom Query interpretation
        /// </summary>
        protected internal async virtual Task <Cursor> DoOpenCursorAsync(OracleConnection cnn, OracleTransaction transaction, Query query)
        {
            var context = new OracleCRUDQueryExecutionContext(this, cnn, transaction);
            var handler = QueryResolver.Resolve(query);

            try
            {
                return(await handler.OpenCursorAsync(context, query).ConfigureAwait(false));
            }
            catch (Exception error)
            {
                throw new OracleDataAccessException(
                          StringConsts.OPEN_CURSOR_ERROR + error.ToMessageWithType(),
                          error,
                          KeyViolationKind.Unspecified,
                          CRUDGenerator.KeyViolationName(error));
            }
        }
Beispiel #5
0
        /// <summary>
        ///  Performs CRUD load without fetching data only returning schema. Override to do custom Query interpretation
        /// </summary>
        protected internal async virtual Task <Schema> DoGetSchemaAsync(OracleConnection cnn, OracleTransaction transaction, Query query)
        {
            if (query == null)
            {
                return(null);
            }

            var handler = QueryResolver.Resolve(query);

            try
            {
                return(await handler.GetSchemaAsync(new OracleCRUDQueryExecutionContext(this, cnn, transaction), query).ConfigureAwait(false));
            }
            catch (Exception error)
            {
                throw new OracleDataAccessException(
                          StringConsts.GET_SCHEMA_ERROR + error.ToMessageWithType(),
                          error,
                          KeyViolationKind.Unspecified,
                          CRUDGenerator.KeyViolationName(error));
            }
        }
Beispiel #6
0
 /// <summary>
 /// Performs CRUD row deletion. Override to do custom deletion
 /// </summary>
 protected internal async override Task <int> DoDeleteAsync(OracleConnection cnn, OracleTransaction transaction, Doc row, IDataStoreKey key = null)
 {
     CheckReadOnly(row.Schema, "delete");
     return(await CRUDGenerator.CRUDDelete(this, cnn, transaction, row, key).ConfigureAwait(false));
 }
Beispiel #7
0
 /// <summary>
 /// Performs CRUD row upsert. Override to do custom upsertion
 /// </summary>
 protected internal async override Task <int> DoUpsertAsync(OracleConnection cnn, OracleTransaction transaction, Doc row, FieldFilterFunc filter = null)
 {
     CheckReadOnly(row.Schema, "upsert");
     return(await CRUDGenerator.CRUDUpsert(this, cnn, transaction, row, filter).ConfigureAwait(false));
 }
Beispiel #8
0
 /// <summary>
 /// Performs CRUD row update. Override to do custom update
 /// </summary>
 protected internal virtual int DoUpdate(OracleConnection cnn, OracleTransaction transaction, Doc row, IDataStoreKey key = null, FieldFilterFunc filter = null)
 {
     checkReadOnly(row.Schema, "update");
     return(CRUDGenerator.CRUDUpdate(this, cnn, transaction, row, key, filter));
 }
Beispiel #9
0
 /// <summary>
 /// Performs CRUD row deletion. Override to do custom deletion
 /// </summary>
 protected internal virtual int DoDelete(OracleConnection cnn, OracleTransaction transaction, Doc row, IDataStoreKey key = null)
 {
     checkReadOnly(row.Schema, "delete");
     return(CRUDGenerator.CRUDDelete(this, cnn, transaction, row, key));
 }
Beispiel #10
0
 /// <summary>
 /// Performs CRUD row upsert. Override to do custom upsertion
 /// </summary>
 protected internal virtual int DoUpsert(OracleConnection cnn, OracleTransaction transaction, Doc row, FieldFilterFunc filter = null)
 {
     checkReadOnly(row.Schema, "upsert");
     return(CRUDGenerator.CRUDUpsert(this, cnn, transaction, row, filter));
 }
Beispiel #11
0
 /// <summary>
 /// Based on store settings, converts query parameters into MySQL-acceptable values, i.e. GDID -> BYTe[].
 /// This function is not idempotent
 /// </summary>
 public void ConvertParameters(OracleParameterCollection pars)
 {
     CRUDGenerator.ConvertParameters(DataStore, pars);
 }
Beispiel #12
0
 /// <summary>
 /// Based on store settings, converts CLR value to Oracle-acceptable value, i.e. GDID -> BYTE[].
 /// </summary>
 public (object value, OracleDbType?dbType) CLRValueToDB(object value, string explicitDbType)
 {
     return(CRUDGenerator.CLRValueToDB(DataStore, value, explicitDbType));
 }
 /// <summary>
 /// Performs CRUD row update. Override to do custom update
 /// </summary>
 protected internal async override Task <int> DoUpdateAsync(OracleConnection cnn, OracleTransaction transaction, Doc row, IDataStoreKey key = null, FieldFilterFunc filter = null)
 {
     CheckReadOnly(row.Schema, "update");
     return(await CRUDGenerator.CRUDUpdate(this, cnn, transaction, row, key, filter));
 }
 /// <summary>
 /// Based on store settings, converts CLR value to MySQL-acceptable value, i.e. GDID -> BYTE[].
 /// </summary>
 public object CLRValueToDB(OracleDataStoreBase store, object value, out OracleDbType?convertedDbType)
 {
     return(CRUDGenerator.CLRValueToDB(DataStore, value, out convertedDbType));
 }