Search code examples
c#linqmodel-view-controller

AND between multiple form clauses


I have this viewModel

var viewModel = from c in _context.Companies
                join co in _context.Component on c.id equals co.company_id 
                select new Joincco { Companies = c, Component = co}  ; 

and another model:

from check in _context.Companies 
where 
    check.company_type.Contains(checkedBoxes[.....]) || 
    check.company_type.Contains(....) || 
    check.company_type.Contains(....) 
select new Joincco { Companies = check }

I need a new view that can provide AND between them. I need to get company_types from Companies that contains specific values and some properties equals a specific value from component.How can I do that?


Solution

  • Used intersect

    return View(deneme.Intersect(longlinq).OrderBy(m => m.Companies.company_name));