Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();

            _store = new SQLiteStore(store_CreateSchema, 4);
            _wpfProxy = new WPFProxy();
            itemsDataGrid.ItemsSource = _store.GetTable("Files").DefaultView;
        }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();

            _store    = new SQLiteStore(store_CreateSchema, 4);
            _wpfProxy = new WPFProxy();
            itemsDataGrid.ItemsSource = _store.GetTable("Files").DefaultView;
        }
Beispiel #3
0
        void store_CreateSchema(object sender, SQLiteConnection cnn, int actualVersion)
        {
            // cnn connection running in transaction

            SQLiteStore store = (SQLiteStore)sender;

            if (actualVersion <= 2)
            {
                // expand new schema

                if (actualVersion == 2)
                {
                    store.DropTable(cnn, "Attributes");
                    store.DropTable(cnn, "Files");
                }

                TableDef tableDef = new TableDef
                {
                    name        = "Attributes",
                    displayName = "File Attributes",
                    columns     = new ColumnDef[] {
                        new ColumnDef {
                            name = "Name", displayName = "Name", type = "NVARCHAR"
                        },
                        new ColumnDef {
                            name = "Value", displayName = "Value", type = "NVARCHAR"
                        },
                        new ColumnDef {
                            name = "FileId", displayName = "FileId", type = "TABLE", parentTable = "Files"
                        }
                    }
                };

                store.AddTable(cnn, tableDef);

                tableDef = new TableDef
                {
                    name        = "Files",
                    displayName = "My Files",
                    columns     = new ColumnDef[] {
                        new ColumnDef {
                            name = "FileName", displayName = "File name", type = "NVARCHAR"
                        },
                        new ColumnDef {
                            name = "FilePath", displayName = "Path", type = "NVARCHAR"
                        },
                        new ColumnDef {
                            name = "FileSize", displayName = "Size", type = "INT"
                        }
                    }
                };

                store.AddTable(cnn, tableDef);
            }
            else if (actualVersion == 3)
            {
                ColumnDef[] newCols = new ColumnDef[] {
                    new ColumnDef {
                        name = "state", displayName = "State", type = "TEXT", defValue = "'n/a'"
                    },
                    new ColumnDef {
                        name = "image_size", displayName = "Image Size", type = "TEXT", defValue = "''"
                    },
                    new ColumnDef {
                        name = "pixel_format", displayName = "Pixel Format", type = "TEXT", defValue = "''"
                    }
                };

                store.AddColumns(cnn, "Files", newCols);
            }
        }