A question asked to the floor in our office was:
What is the difference between
Method 1
var team = _db.Get<ClientCreateDefaults>(c => c.ClientRef == newCase.ClientRef &&
c.WorkTypeCode == newCase.WorkTypeCode);
Method 2
var team = _db.Get<ClientCreateDefaults>(c => c.ClientRef ==
newCase.ClientRef).Where(w => w.WorkTypeCode == newCase.WorkTypeCode);
Method 3
var team = _db.Get<ClientCreateDefaults>().Where(w => w.WorkTypeCode ==
newCase.WorkTypeCode).Where(c => c.ClientRef == newCase.ClientRef);
An answer was given:
If this is our
DataContext
:The first one, the conditions will all be translated into SQL, so the filtering will happen on the db server.
The second one only does the first one on the db server and then filters by
WorkTypeCode
on the client side.The third one will filter all client side and get all of the items from the db.
Is this correct? Does linq really bring whole datasets to the client side?