Ejemplo n.º 1
0
 public void Commit()
 {
     if (!_wasCommitted)
     {
         _database.Execute("COMMIT");
         _wasCommitted = true;
     }
 }
Ejemplo n.º 2
0
        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());
            }
        }
Ejemplo n.º 3
0
 public SqliteTransaction(SqliteDatabase database)
 {
     _database = database;
     _database.Execute("BEGIN TRANSACTION");
 }
Ejemplo n.º 4
0
        public void CreateTable(SqliteDatabase database)
        {
            var sql = CreateTableSql();

            database.Execute(sql);
        }