public DataModel() { List <Entry> list = new List <Entry>(); int limit = db.GetCatalogLength(); for (int i = 0; i < limit; i++) { if (db.DoesEntryExists(i)) { list.Add(new Entry() { Author = db.GetAuthorOfEntry(i), Title = db.GetTitleOfEntry(i), BookCount = db.GetBookCountByEntry(i), Index = i }); } else { limit++; } } Data = list; }