【问题标题】:linq join with less than or equal to int valuelinq join 小于或等于 int 值
【发布时间】:2012-02-08 10:19:15
【问题描述】:

我想知道 where 子句的最佳方法,它小于或等于要匹配的值为 int 的位置?

var outOfStockProducts = (from theMapProd in context.tblProductOptions_MAP
                          join theProd in context.tblProducts on theMapProd.productID equals theProd.productID
                          where theProd.stock_Level  <= 5
                          select theMapProd).ToList();

【问题讨论】:

  • 您对收到的查询有什么顾虑?

标签: linq entity-framework linq-to-entities where


【解决方案1】:

这是另一种方式, 未测试。

var outOfStockProducts = (from theMapProd in context.tblProductOptions_MAP
                      join theProd in context.tblProducts on theMapProd.productID equals theProd.productID
                      select theMapProd).ToList();

outOfStockProducts=outOfStockProducts.where(x=>x.stock_Level  < 5 || x.stock_Level ==5).ToList();

【讨论】:

  • 这比原来的查询差很多
猜你喜欢
  • 2017-06-16
  • 2016-12-10
  • 2014-11-01
  • 1970-01-01
  • 2011-01-25
  • 2013-09-02
  • 1970-01-01
  • 2012-10-14
  • 2016-09-30
相关资源
最近更新 更多