EF data repositories are being implemented, and we have several queries that would involve
I've seen several postings that recommend using
The code I'm examining utilizes
I am aware that both of these provide the same outcome for object assignment, but do they both go to the same query in reality? Will the DB truly be consulted when a query is made?
to both inquiries? Or will they just grab the first item in the collection after fully executing the query into the enumerable?
Additionally, if we applied
So why should we anticipate any other behavior? I am aware that invoking an IEnumerable
throwing will occur on an empty collection, however if this is merely altering the query to include
thus there should be no functional difference at all between
Alternatively, is there a more effective way to make the query run than these Enumerable extensions?
zzz-5 to zzz:
age_Centers.Select(c => c.Id).First(); age_Centers.Select(c => c.Id).FirstOrDefault(); age_Centers.Select(c => c.Id).Take(1).Dump();
SELECT TOP (1) [t0].[Id] FROM [age_Centers] AS [t0] GO SELECT TOP (1) [t0].[Id] FROM [age_Centers] AS [t0] GO SELECT TOP (1) [t0].[Id] FROM [age_Centers] AS [t0]
returns an after enumerating