/// <summary> /// Executes a request to insert several values in a table. /// </summary> /// <parameters> /// <param name="context">Description of the request.</param> /// </parameters> /// <returns> /// The request result. /// </returns> public IInsertResult Run(IInsertContext context) { Debug.Assert(Connector != null); Debug.Assert(Connector.IsOpen); return(Execute(context)); }
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public Task <IInsertResult> RunAsync(IInsertContext context) #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member { Debug.Assert(Connector != null); Debug.Assert(Connector.IsOpen); return(Task.Run(() => Execute(context))); }
/// <summary> /// Executes a request to insert several values in a table. /// This is the synchronous implementation. /// </summary> /// <parameters> /// <param name="context">Description of the request.</param> /// </parameters> /// <returns> /// The request result. /// </returns> protected virtual IInsertResult Execute(IInsertContext context) { if (!IsOperationThreadStarted) { return(new InsertResult(false, ResultError.ErrorFatalNoOperationThread)); } if (context.RowCount == 0 || context.EntryList.Count == 0) { return(new InsertResult(true, ResultError.ErrorNone)); } IActiveOperation <IInsertResultInternal> ActiveOperation = Connector.Insert(context); IInsertResultInternal Result = ActiveOperation.Result; FinalizeOrQueue(ActiveOperation); return(Result); }
public override IActiveOperation <IInsertResultInternal> Insert(IInsertContext context) { if (ServerVersionMajor < 8) { IColumnDescriptor PrimaryKey = context.Table.PrimaryKey; bool HasPrimary = false; foreach (IColumnValueCollectionPair Entry in context.EntryList) { if (Entry.Column == PrimaryKey) { HasPrimary = true; break; } } if (!HasPrimary && (PrimaryKey is IColumnDescriptorGuid)) { return(new ActiveOperation <IInsertResultInternal>(new InsertResult(false, ResultError.ErrorPrimaryKeyRequired))); } } IMySqlInsertOperation Operation = new MySqlInsertOperation(context); IReadOnlyCollection <IColumnValueCollectionPair <byte[]> > DataCollectionEntryList = Operation.GetDataEntryList(); List <IColumnValuePair <byte[]> > DataEntryList = new List <IColumnValuePair <byte[]> >(); foreach (IColumnValueCollectionPair <byte[]> Entry in DataCollectionEntryList) { foreach (byte[] Value in Entry.ValueCollection) { DataEntryList.Add(new ColumnValuePair <byte[]>(Entry.Column, Value)); } } return(PrepareNonQueryOperationWithParameter <IInsertContext, IMySqlInsertOperation, IInsertOperation, IInsertResult, IInsertResultInternal>( Operation, DataEntryList, (IInsertOperation operation, IAsyncResult asyncResult) => new InsertResult(operation, asyncResult), (MySqlCommand command, IInsertResultInternal result) => Operation.FinalizeOperation(command, result))); }
public abstract IActiveOperation <IInsertResultInternal> Insert(IInsertContext context);
public MySqlInsertOperation(IInsertContext context) : base(context) { }