I have the following query:
var vendors = (from pp in this.ProductPricings
join pic in this.ProductItemCompanies
on pp.CompanyId equals pic.CompanyId into left
from pic in left.DefaultIfEmpty()
orderby pp.EffectiveDate descending
group pp by new { pp.Company, SortOrder = (pic != null) ? pic.SortOrder : short.MinValue } into v
select v).OrderBy(z => z.Key.SortOrder);
Does anyone know how the last OrderBy()
is applied? Does that become part of the SQL query, or are all the results loaded in to memory and then passed to OrderBy()
?
And if it's the second case, is there any way to make it all one query? I only need the first item and it would be very inefficent to return all the results.