c# - Iqueryable as a subquery to filter another iqueryable -


i have many many relationship (sites, categories, categoriesxsite) , 2 iqueryable defined variables this:

iqueryable<site> sitesquery = s in db.sites                          s.name.contains(siteword)                          select s    iqueryable<sitecategorie> categoriesquery = c in db.sitecategories                                        c.parent.id == 1                                        select c; 

i want able apply filter categories iqueryable based on sites iqueryable way can have categories filters plus filter of categories has sites containing filter, thing this:

from c in categoriesquery  c.sites == sitesquery select c 

i've made similar question before when didn't need filter categories (here)

thanks lot,

you'll want either

from c in categoriesquery   c.sites.any(s => sitesquery.contains(s)) select c  

or

from c in categoriesquery   c.sites.all(s => sitesquery.contains(s)) select c  

depending on use case.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -