string keyword = "michio kaku";
using (MyModelEntities db = new MyModelEntities())
{
long? maxId = db.ResultDatas.Select(m => m.Query == Keyword).Max(m => db.ResultDatas.Max(r => r.ResultId));
}In the code above, I have an Entity Set named "ResultDatas" with some fields "Query" and "ResultId".
The underlying data store could have 0 to n matches for a given query. I want to return the max(ResultId) of the matched keyword (or null for non-matched sets).
The code above works, but seems ineffecient, can someone explain a better way to do this?
TIA
Add your 2¢