// entities linq - how to get first record from the table
using (SchoolEntities schoolContext = new SchoolEntities())
{
var firstRecord = (from c in schoolContext.Course
orderby c.CourseID ascending
select c).First();
}
// now get last record from the table
using (SchoolEntities schoolContext = new SchoolEntities())
{
var lastRecord = (from c in schoolContext.Course
orderby c.CourseID descending
select c).First();
}
No comments:
Post a Comment