Ejemplo n.º 1
0
 public static Task <SqliteDictionaryReader> ExecuteSelectAsync(
     SqliteDatabaseConnection connection, string table, IEnumerable <string> keys, string?restOfQuery = null,
     IDictionary <string, object>?parameters = null
     )
 {
     keys = keys.ToList();
     restOfQuery ??= "";
     return(ExecuteReaderAsync(connection, $"SELECT {string.Join(", ", keys)} FROM {table} {restOfQuery}", keys, parameters));
 }
Ejemplo n.º 2
0
        public static async Task <SqliteDictionaryReader> ExecuteReaderAsync(
            SqliteDatabaseConnection connection, string commandText, IEnumerable <string> keys,
            IDictionary <string, object>?parameters = null
            )
        {
            var command = connection.CreateCommand(commandText, parameters);
            var reader  = await command.ExecuteReaderAsync();

            return(new SqliteDictionaryReader(reader, keys, command));
        }
Ejemplo n.º 3
0
        public async Task MigrateAsync(SqliteDatabaseConnection connection)
        {
            using var transaction = connection.Connection.BeginTransaction();
            // With the transaction, any exceptions will be thrown as normal, but changes will not commit unless
            // the function successfully runs till the end.

            this.beforeMigrate?.Invoke(connection);
            if (this.command != null)
            {
                _ = await connection.ExecuteNonQueryAsync(this.command);
            }
            _ = await connection.ExecuteNonQueryAsync($"UPDATE __version SET version = {this.Version}");

            this.afterMigrate?.Invoke(connection);

            transaction.Commit();
        }