How do I navigate a table using the entity framework?
I'm trying to create a simple table navigation screen in WPF using the entity framework on a database with one table, Studen开发者_开发百科ts. The screen basically has the the students name and surname and back and forwards button. The datacontext is pointing directly to the Students table and is setup as follows:
private DBEntities _entity = new DBEntities();
this.Datacontext = _entity.Students;
This works and I see the first entry on the table on the screen. My problem is I can't see any way to navigate to the next entry when I click the next button. There is First() method on Students but no Next().
All the solutions I've found via google dump the entire table in a List and navigate the list.
I'm wondering if there isn't a simpler way that I'm missing?
msdn topic here...
First get the collection as an ICollectionView
,
ICollectionView view1 = CollectionViewSource.GetDefaultView(_entity.Students);
Now you can navigate the collection, in this case you can use MoveCurrentToNext
精彩评论