好的,所以我已经问过这个问题,但是我已经把它缩小了,我现在能够更好地说出来了。
我有一个sql数据库和一个带有实体框架的asp.net mvc项目。 我已经想出了如何查询数据库并显示所有内容。 但现在我需要查询数据库,只显示列“a”大于或等于列“b”的行。
编辑:两列中的数据类型都是int
这是我需要的查询
Select * from Inventory Where quantity <= statusLowOkay so I've already asked this question but I've narrowed it down and am now able to word it better.
I have a sql database and an asp.net mvc project with entity frameworks. I already figured out how to query the database and display all contents. But now I need to query the database and only display the rows where column "a" is greater than or equal to column "b".
Edit: datatypes in both columns are int
Here is the query I need
Select * from Inventory Where quantity <= statusLow最满意答案
您可以尝试如下所示。
using (var db = new yourContext()) { var result = db.Inventory.Where(a=> a.quantity <= a.statusLow).ToList(); }您可以在此处了解有关LINQ to Entities的更多信息。
You can try as shown below.
using (var db = new yourContext()) { var result = db.Inventory.Where(a=> a.quantity <= a.statusLow).ToList(); }You can learn more about LINQ to Entities here.
更多推荐
发布评论