Ejemplo n.º 1
0
 private void SQLiteDataEntityImpl(bool initDb = true, bool isReadOnly = false)
 {
     _tableName  = typeof(T).Name;
     _isReadOnly = isReadOnly;
     if (initDb)
     {
         InitEntityDatabase();
     }
     else
     {
         _table = AppDatabase.Current.Tables[_tableName];
     }
 }
Ejemplo n.º 2
0
        private void refreshTables()
        {
            var tables = this.SqliteDb.Query <Table>("SELECT * FROM 'Table'");

            foreach (var table in tables)
            {
                if (!Tables.ContainsKey(table.Name))
                {
                    TableDatabase tblDB = new TableDatabase(table.Name);
                    Tables.Add(table.Name, tblDB);
                }
            }
        }
Ejemplo n.º 3
0
        //todo: optimization on columns to determine if they changed and thus do a DeleteAllColumns and rebuild
        private void InitEntityDatabase()
        {
            AppDatabase.Current.AddTable(_tableName, _defaultCreator);
            _table = AppDatabase.Current.Tables[_tableName];

            _table.DeleteAllColumns();  //note: we delete all columns and rebuild them from the current class to ensure new columns exist

            var props = typeof(T).GetTypeInfo().DeclaredProperties;

            foreach (var prop in props)
            {
                _table.AddColumn(prop.Name, _defaultCreator);
            }

            _table.AddColumn("UniqueId", _defaultCreator);
        }