Drew Ilgenfritz Drew Ilgenfritz - 6 months ago 22
ASP.NET (C#) Question

Query with linq using a where clause

Okay 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


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.