好吧,我已经问过这个问题了,但我已经缩小了范围,现在可以更好地表达它了。
我有一个 sql 数据库和一个带有 Entity Framework 的 asp.net mvc 项目。我已经想出了如何查询数据库并显示所有内容。但现在我需要查询数据库,只显示“a”列大于或等于“b”列的行。
编辑:两列中的数据类型都是 int
这是我需要的查询
Select *
from Inventory
Where quantity <= statusLow
最佳答案
var context = new MyContext();
var query = context.Inventory.Where(p=> p.quantity <= p.statusLow); // write the statement to query
var result = query.ToList(); // obtaining the result, trigger the database
关于c# - 使用 where 子句查询 linq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40077430/