Is there any difference between these two ways of querying the context?
Firm firm = base.context.Firms
.Where(f => f.SomeId == someId)
.Where(f => f.AnotherId == anotherId)
.FirstOrDefault();
Firm firm = base.context.Firms
.Where(f => f.SomeId == someId && f.AnotherId == anotherId)
.FirstOrDefault();
It seems that chaining is perfectly fine to accomplish the AND condition. I don’t believe you can chain OR statements. Is there a reason to prefer one over another, or scenarios when one is better/more efficient?
They should both produce the same end result (if I’m not mistaken) but I find the the second is more readable and better shows the original intent.
Update
I just verified the above statement using LINQPad. Both queries will, in fact, product the same SQL.
For example:
Produces:
Which is the same SQL that is produced by:
You could also compact things a little more (which I find preferable for the same reasons as above):