score:3

Accepted answer

Sounds like you probably want:

var next = table.Where(item => item.id > lastId &&
                               item.projects_ID == projects_ID &&
                               item.language == language)
                .OrderBy(item => item.id)
                .FirstOrDefault();

Or as a query expression:

var next = (from item in table
            where item.id > lastId &&
                  item.projects_ID == projects_ID &&
                  item.language == language
            orderby item.id
            select item).FirstOrDefault();

The result will be null if there are no matches (e.g. if you're already looking at the last ID). This is assuming by "next" you mean "matching item with the lowest ID greater than the current one".


Related Articles