/// <summary> /// Performs CRUD load. Override to do custom Query interpretation /// </summary> protected internal async virtual Task <List <RowsetBase> > DoLoadAsync(MySqlConnection cnn, MySqlTransaction 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 MySqlCrudQueryExecutionContext(this, cnn, transaction), query, oneDoc).ConfigureAwait(false); result.Add(rowset); } catch (Exception error) { throw new MySqlDataAccessException( StringConsts.LOAD_ERROR + error.ToMessageWithType(), error, KeyViolationKind.Unspecified, CrudGenerator.KeyViolationName(error)); } } return(result); }
/// <summary> /// Performs CRUD load. Override to do custom Query interpretation /// </summary> protected internal async virtual Task <Cursor> DoOpenCursorAsync(MySqlConnection cnn, MySqlTransaction transaction, Query query) { var context = new MySqlCrudQueryExecutionContext(this, cnn, transaction); var handler = QueryResolver.Resolve(query); try { return(await handler.OpenCursorAsync(context, query).ConfigureAwait(false)); } catch (Exception error) { throw new MySqlDataAccessException( StringConsts.OPEN_CURSOR_ERROR + error.ToMessageWithType(), error, KeyViolationKind.Unspecified, CrudGenerator.KeyViolationName(error)); } }
/// <summary> /// Performs CRUD execution of queries that do not return result set. Override to do custom Query interpretation /// </summary> protected internal async virtual Task <Doc> DoExecuteAsync(MySqlConnection cnn, MySqlTransaction transaction, Query query) { if (query == null) { return(null); } var handler = QueryResolver.Resolve(query); try { return(await handler.ExecuteProcedureAsync(new MySqlCrudQueryExecutionContext(this, cnn, transaction), query).ConfigureAwait(false)); } catch (Exception error) { throw new MySqlDataAccessException( StringConsts.EXECUTE_WITHOUT_FETCH_ERROR + error.ToMessageWithType(), error, KeyViolationKind.Unspecified, CrudGenerator.KeyViolationName(error)); } }
/// <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(MySqlParameterCollection pars) { CrudGenerator.ConvertParameters(DataStore, pars); }
/// <summary> /// Based on store settings, converts CLR value to MySql-acceptable value, i.e. GDID -> BYTE[]. /// </summary> public (object value, MySqlDbType?dbType) CLRValueToDB(object value, string explicitDbType) { return(CrudGenerator.CLRValueToDB(DataStore, value, explicitDbType)); }
/// <summary> /// Performs CRUD row upsert. Override to do custom upsertion /// </summary> protected internal async override Task <int> DoUpsertAsync(MySqlConnection cnn, MySqlTransaction transaction, Doc row, FieldFilterFunc filter = null) { CheckReadOnly(row.Schema, "upsert"); return(await CrudGenerator.CRUDUpsert(this, cnn, transaction, row, filter).ConfigureAwait(false)); }
/// <summary> /// Performs CRUD row deletion. Override to do custom deletion /// </summary> protected internal async override Task <int> DoDeleteAsync(MySqlConnection cnn, MySqlTransaction transaction, Doc row, IDataStoreKey key = null) { CheckReadOnly(row.Schema, "delete"); return(await CrudGenerator.CRUDDelete(this, cnn, transaction, row, key).ConfigureAwait(false)); }