【问题标题】:AND between multiple form clauses多个形式子句之间的AND
【发布时间】:2023-02-10 17:59:55
【问题描述】:

我有这个视图模型

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}  ; 

和另一个模型:

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

我需要一个可以在它们之间提供 AND 的新视图。 我需要从包含特定值的公司获取 company_types,并且某些属性等于来自组件的特定值。我该怎么做?

【问题讨论】:

  • 你到底是什么意思“和”?有不止一种方式来解释它。 “联盟”从一开始就是一切一切从第二开始。 “Intersect[ion]”是第一个中的所有内容第二。看看这有多令人困惑?哪个术语描述了你想要什么?顺便说一下,LINQ 有UnionIntersect 两种方法!
  • 正如我所说,必须满足公司的条件和组件的条件,但 Union 可能有效,我会尝试@madreflection
  • 感谢相交作品@madreflection

标签: c# linq model-view-controller


【解决方案1】:

使用intersect

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-21
    • 2020-08-03
    • 1970-01-01
    • 2012-03-21
    • 2014-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多