简体   繁体   中英

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, Students. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM