Any way for linq query to check against existing select?
- by danrhul
I have an an offer, that can be in any number of categories. I don't however want that offer to then appear twice or however more.
I was wondering if its possible to have a where clause that ascertains whether that offer already exists in that select statement and if so obviously to ignore it.
Here is the linq query:
Offers = from o in offerCategories
orderby o.RewardCategory.Ordering, o.Order
where o.RewardOffer.IsDeleted == false
select new OfferOverviewViewModel
{
Partner = o.RewardOffer.Partner,
Description = String.Format("{0} {1}", o.RewardOffer.MainTitle, o.RewardOffer.SecondaryTitle),
OfferId = o.OfferId,
FeaturedOffer = o.RewardOffer.FeaturedOfferOrder.HasValue,
Categories = from c in offerCategories.Where(oc => oc.OfferId == o.OfferId)
orderby c.RewardCategory.Ordering
select new CategoryDetailViewModel
{
Description = c.RewardCategory.DisplayName
}
},