Turns out the query I was using above was completly wrong to begin with.

long? maxId = db.ResultDatas.Where(model => model.Query == Keyword).Max(res => (long?)res.ResultId) ?? 0;

The above code works, is intuitive and seems to be reasonably performant.

If anyone knows any better please let me know!