Ejemplo n.º 1
0
        private async void Insert(string table, dynamic parameters)
        {
            await Initialized();

            MultiRow multiRow = await ParseMultiRow(table, parameters);

            await mysql.Query(multiRow.CommandText, multiRow.Parameters);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Insert wrapper for multiple rows, should be able to do single rows too
        /// </summary>
        /// <param name="table">Name of the table where the data is inserted</param>
        /// <param name="parameters">List of dictionaries each representing a row to be inserted</param>
        /// <param name="callback">FiveM callback function</param>
        /// <param name="lastInsertId">return the last insert id if true, otherwise affected rows</param>
        private async void Insert(string table, dynamic parameters, CallbackDelegate callback = null, bool lastInsertId = false)
        {
            await Initialized();

            MultiRow multiRow = await ParseMultiRow(table, parameters);

            bool isInsert = (callback == null) ? false : lastInsertId;
            long result   = await mysql.Query(multiRow.CommandText, multiRow.Parameters, isInsert);

            if (callback != null)
            {
                await Delay(0);

                callback.Invoke(result);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Parsing MultiRow with the TaskScheduler to avoid hitches
 /// </summary>
 /// <param name="table">Name of the table</param>
 /// <param name="parameters">List of dictionarys which represent each row inserted</param>
 /// <returns>Returns the MultiRow object which consists of a built query string and a set of parameters</returns>
 private async Task <MultiRow> ParseMultiRow(string table, dynamic parameters) => await Task.Factory.StartNew(() =>
 {
     return(MultiRow.TryParse(table, parameters));
 }, CancellationToken.None, TaskCreationOptions.None, taskScheduler);