private bool SaveInsert(ITransaction transaction) { SchemaObject schemaObject = Schema.Schema.GetSchemaObject(GetType()); IInsertQuery insertQuery = SQLProviderFactory.GetInsertQuery(); insertQuery.Table = new Table(schemaObject.SchemaName, schemaObject.ObjectName); foreach (Schema.Field field in schemaObject.GetFields()) { if (field == schemaObject.PrimaryKeyField) { continue; } FieldValue fieldValue = new FieldValue(); fieldValue.FieldName = field.FieldName; fieldValue.Value = field.GetValue(this); insertQuery.FieldValueList.Add(fieldValue); } long?primaryKey = insertQuery.Execute(transaction); if (primaryKey != null) { schemaObject.PrimaryKeyField.SetPrivateDataCallback(this, primaryKey); return(true); } return(false); }
public static IInsertQuery CreateInsertQuery(string db, DbProviderType provider) { IInsertQuery query = CreateInsertQuery(db); query.DbProviderType = provider; return(query); }
public override async Task <InsertQueryResult> QueryAsync(IInsertQuery query) { var b = Batch.CreateSimple(this); var res = b.QueryAsync(query); await b.Execute(); return(res.Result); }
public override async Task <InsertQueryResult> QueryAsync(IInsertQuery insertQuery) { var b = Batch.CreateUsingTransaction(this); var res = b.QueryAsync(insertQuery); await b.Execute(); return(res.Result); }
/// <summary> /// Initializes a new instance of the <see cref="InsertODKUQueryBase"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="settings">The <see cref="IQueryBuilderSettings"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="parent"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="settings"/> is null.</exception> protected InsertODKUQueryBase(IInsertQuery parent, IQueryBuilderSettings settings) { if (parent == null) throw new ArgumentNullException("parent"); if (settings == null) throw new ArgumentNullException("settings"); _parent = parent; _settings = settings; _c = new ColumnValueCollectionBuilder<IInsertODKUQuery>(this, settings); }
public override Task <InsertQueryResult> QueryAsync(IInsertQuery insertQuery) { _combinedRawQuery.Append(insertQuery.GetRawQuery()); _combinedRawQuery.Append(";\n"); IsEmpty = false; var tcs = new TaskCompletionSource <InsertQueryResult>(); _resultProcessors.Add(async reader => { tcs.SetResult(await insertQuery.ReadResultAsync(reader)); }); return(tcs.Task); }
/// <summary> /// Initializes a new instance of the <see cref="InsertODKUQueryBase"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="settings">The <see cref="IQueryBuilderSettings"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="parent"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="settings"/> is null.</exception> protected InsertODKUQueryBase(IInsertQuery parent, IQueryBuilderSettings settings) { if (parent == null) { throw new ArgumentNullException("parent"); } if (settings == null) { throw new ArgumentNullException("settings"); } _parent = parent; _settings = settings; _c = new ColumnValueCollectionBuilder <IInsertODKUQuery>(this, settings); }
/// <summary> /// When overridden in the derived class, creates an <see cref="IInsertODKUQuery"/> instance. /// </summary> /// <param name="parent">The <see cref="IInsertQuery"/> to use as the parent.</param> /// <returns>The <see cref="IInsertODKUQuery"/> instance.</returns> protected override IInsertODKUQuery CreateInsertODKUQuery(IInsertQuery parent) { return new MySqlInsertODKUQuery(parent); }
/// <summary> /// When overridden in the derived class, creates an <see cref="IInsertODKUQuery"/> instance. /// </summary> /// <param name="parent">The <see cref="IInsertQuery"/> to use as the parent.</param> /// <returns>The <see cref="IInsertODKUQuery"/> instance.</returns> protected override IInsertODKUQuery CreateInsertODKUQuery(IInsertQuery parent) { return(new MySqlInsertODKUQuery(parent)); }
public void Reset() { InsertQuery = new InsertQuery(); }
/// <summary> /// Initializes a new instance of the <see cref="MySqlInsertODKUQuery"/> class. /// </summary> /// <param name="parent">The parent.</param> public MySqlInsertODKUQuery(IInsertQuery parent) : base(parent, MySqlQueryBuilderSettings.Instance) { }
/// <summary> /// When overridden in the derived class, creates an <see cref="IInsertODKUQuery"/> instance. /// </summary> /// <param name="parent">The <see cref="IInsertQuery"/> to use as the parent.</param> /// <returns>The <see cref="IInsertODKUQuery"/> instance.</returns> protected abstract IInsertODKUQuery CreateInsertODKUQuery(IInsertQuery parent);
/// <summary> /// Initializes a new instance of the <see cref="MySqlInsertODKUQuery"/> class. /// </summary> /// <param name="parent">The parent.</param> public MySqlInsertODKUQuery(IInsertQuery parent) : base(parent, MySqlQueryBuilderSettings.Instance) { }
public abstract Task <InsertQueryResult> QueryAsync(IInsertQuery insertQuery);
/// <summary> /// When overridden in the derived class, creates an <see cref="IInsertODKUQuery"/> instance. /// </summary> /// <param name="parent">The <see cref="IInsertQuery"/> to use as the parent.</param> /// <returns>The <see cref="IInsertODKUQuery"/> instance.</returns> protected abstract IInsertODKUQuery CreateInsertODKUQuery(IInsertQuery parent);