I have a web app that displays the details of some entity, let's call it Log
. The entity is loaded from SQL Server via Entity Framework 4.
I would like to provide 'next' and 'previous' links to walk through logs bidirectionally.
Logs are ordered by two properties/columns:
Both of these columns may contain null
, and there is no guarantee of uniqueness. If both of these values are null, then in order to guarantee a stable sort I order by the database Id
, which is guaranteed to be non-null and unique.
Furthermore there may not actually be an entity before or after a given Log
.
There are some other questions that address doing this with SQL directly. I'd like to know how to do this with the Entity Framework, ideally making only a single trip to the DB to bring back a few fields for this pair of Logs
(id, title, etc).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…