public void Commit() { if (!_wasCommitted) { _database.Execute("COMMIT"); _wasCommitted = true; } }
public void AddMissingColumns(SqliteDatabase database) { CreateTable(database); var currentFields = new HashSet <string>(); using (var reader = database.Read($"PRAGMA table_info({TableName})")) { while (reader.TryRead()) { var column = reader.ColumnText(1); if (column != null) { currentFields.Add(column); } } } var missingFields = new List <SqliteProperty <T> >(_properties); missingFields.RemoveAll(p => currentFields.Contains(p.ColumnName)); var builder = new StringBuilder(); foreach (var field in missingFields) { builder.Length = 0; builder .Append("ALTER TABLE ") .AppendField(TableName) .Append(" ADD COLUMN ") .AppendProperty(field); database.Execute(builder.ToString()); } }
public SqliteTransaction(SqliteDatabase database) { _database = database; _database.Execute("BEGIN TRANSACTION"); }
public void CreateTable(SqliteDatabase database) { var sql = CreateTableSql(); database.Execute(sql); }