I have a simple entity framework query. It uses grouping:
source.GroupBy(x => x.Key)
.Select(x => x.Count(z => z.IsDefaultValue == false) > 0
? x.FirstOrDefault(z => z.IsDefaultValue == false)
: x.FirstOrDefault()
);
Execution plan for it looks like this:
Then I change the query:
source.GroupBy(x => x.Key)
.Select(x => x.Any(z => z.IsDefaultValue == false)
? x.FirstOrDefault(z => z.IsDefaultValue == false)
: x.FirstOrDefault()
);
Now I use Any instead of Count.
It's plan looks like this:
My question is: what query should I use? What query is more efficient?
I don't understand anything about execution plans :( What important information do you see on these execution plans?
EDIT: Please drag pictures in a new tab, it will be more readable.