public HistoryWindowController(SQLiteConnection dbConnection, string table) { _dbConnection = dbConnection; _dbConnection.Update += DatabaseUpdated; _table = table; DataContext = new ControllerDataContext() { Entries = new ObservableCollection<TableStruct>(), Title = table }; var query = "SELECT * FROM " + table; var command = new SQLiteCommand(query, dbConnection); var reader = command.ExecuteReader(); var viewIndex = 1; while (reader.Read()) { var entry = new TableStruct() { Id = (long)reader["Id"], ViewIndex = viewIndex, Rank = (int)reader["Rank"], Date = (DateTime)reader["Date"] }; viewIndex++; entry.PropertyChanged += EntryChanged; DataContext.Entries.Add(entry); } DataContext.Entries.CollectionChanged += EntriesUpdated; }
public HistoryWindowController(SQLiteConnection dbConnection, string table) { _dbConnection = dbConnection; _dbConnection.Update += DatabaseUpdated; _table = table; DataContext = new ControllerDataContext() { Entries = new ObservableCollection <TableStruct>(), Title = table }; var query = "SELECT * FROM " + table; var command = new SQLiteCommand(query, dbConnection); var reader = command.ExecuteReader(); var viewIndex = 1; while (reader.Read()) { var entry = new TableStruct() { Id = (long)reader["Id"], ViewIndex = viewIndex, Rank = (int)reader["Rank"], Date = (DateTime)reader["Date"] }; viewIndex++; entry.PropertyChanged += EntryChanged; DataContext.Entries.Add(entry); } DataContext.Entries.CollectionChanged += EntriesUpdated; }