Reputation: 1800
I have the following query in linq:
(from creditCard in DbSet
join rank in base.dataContext.ProductVerticalRanks on creditCard.ProductVerticalReferenceId equals rank.ProductVerticalReferenceId
where rank.ClientId == clientId
orderby rank.PreferredOrder
select creditCard)
.Include(creditCard => creditCard.ProductVerticalCompany)
.Include(creditCard => creditCard.Labels);
But now I have a new requirement, I need to add a column 'rank.PreferredOrder' from table 'rank' into the result, is there an easy way of doing this without making a massive 'select' statement, because there are around 20-30 fields in creditCard alone.
Upvotes: 0
Views: 470
Reputation: 11681
I dont have your model in front of me, so can't confirm this or not, but you can use an anonymous object like this:
from creditCard in DbSet
join rank in base.dataContext.ProductVerticalRanks on
creditCard.ProductVerticalReferenceId equals rank.ProductVerticalReferenceId into g
where rank.ClientId == clientId
orderby rank.PreferredOrder
select new {Card = creditCard, Ranks = g}
Upvotes: 2