I make a second request below, incremented by 'a' and 'b' ('b' increases to the limit, then reset and 'a' increases). There may be several lines with the given values ββ"a" and "b".
struct MyData {int mdA; int mydB; } .... int find_next_a(int a, int b) { var q = from p in db.pos where (pa >= a && pb > b) || (pa > a && pb > 0) orderby pa, pb select new MyData { mdA = pa, mdB = pb }; return q.First().mdA;
The query works until I get to the end of the table. Then I get an InvalidOperationException. I cannot call q.Count () because I get the same exception.
How can I find that q does not have any reliable data in it?
[ EDIT :] Thanks Jon Skeet (and Bojan Skrchevski, Bodrick), I post the solution above.
int find_next_a(int a, int b) { var q = from p in db.pos where (pa >= a && pb > b) || (pa > a && pb > 0) orderby pa, pb select new { pa, pb }; var result = q.FirstOrDefault();
source share