Hi,
I would like some help on how to write a linq query which retrieves articles of a certain category. I've built a site that contains pages, news and category. A page can have on and only one category apointed to it while a newsitem can have several categories appointed to it. When on a page, I would like to retrieve the newsitems which have the same category as the page. How do I go about doing that?
Both the page and newsitems uses Umbracos multinode treepicker to select categories from the category folder. I've managed to retrieve the category for the page and if a newsitem only could have one category assigned to it there wouldn't be any problem. Then I could just use FirstOrDefault():
Select articles which contains a certain category
Hi, I would like some help on how to write a linq query which retrieves articles of a certain category. I've built a site that contains pages, news and category. A page can have on and only one category apointed to it while a newsitem can have several categories appointed to it. When on a page, I would like to retrieve the newsitems which have the same category as the page. How do I go about doing that?
Both the page and newsitems uses Umbracos multinode treepicker to select categories from the category folder. I've managed to retrieve the category for the page and if a newsitem only could have one category assigned to it there wouldn't be any problem. Then I could just use FirstOrDefault():
But how should it be written when there can be multiple categories?
Kind regards /Björn
Hi,
Try
I've written categories but you might have this as "category"?
HTH
Steve
Awesome, that's exactly what I needed. Thanks.
/Björn
Cool - glad it worked!
is working on a reply...