|
|
|
|
|
by Jestar342
1952 days ago
|
|
It can be extended upon.. I see a lot of ORM based solutions that pull a full record just to check a single property sometimes. E.g.: var user = repository.GetUserById(userId);
return user.IsDisabled;
That's not even a facetious example, I have seen it multiple times. In some cases that query is pulling multiple columns, and a few joins.. just to pull a single bit value. |
|
In that scenario, this can be strictly more efficient than doing a specialized query here, and a more general fetch of the user later, because it becomes just one sql command instead of two.
Obviously though there are ORMs that don't offer such caching, or cases where the value will not be used again elsewhere in the request, and in those cases this is clearly undesirable. It is generally quicker and easier to do this than adding a new custom method to the repository to get exactly the desired data which is why it remains common even in those scenarios.