private void loadAllBooks(IDbConnection connection) { if (_allBooks == null) { _allBooks = new ObservableCollection <IBook>(); _allBooksReadOnly = new ReadOnlyObservableCollection <IBook>(_allBooks); IDbCommand select = connection.CreateCommand(); select.CommandText = String.Format("SELECT {0}, BookTitle FROM Books", itemIdFieldsForSelect); using (IDataReader reader = select.ExecuteReader()) { while (reader.Read()) { ReplicaItemId id = getReplicaItemIdFromDataReader(reader); string title = Convert.ToString(reader["BookTitle"]); Book item = new Book(this, id, title); _allBooks.Add(item); } } } }
private void loadAllPeople(IDbConnection connection) { if (_allPeople == null) { _allPeople = new ObservableCollection <IPerson>(); _allPeopleReadOnly = new ReadOnlyObservableCollection <IPerson>(_allPeople); IDbCommand select = connection.CreateCommand(); select.CommandText = String.Format("SELECT {0}, PersonName FROM People", itemIdFieldsForSelect); using (IDataReader reader = select.ExecuteReader()) { while (reader.Read()) { ReplicaItemId id = getReplicaItemIdFromDataReader(reader); string name = Convert.ToString(reader["PersonName"]); Person item = new Person(this, id, name); _allPeople.Add(item); } } } }