LINQ Conditional Where Clauses not working

前端 未结 4 1922
不思量自难忘°
不思量自难忘° 2020-12-22 12:16

Using: MVC 5, C#, VS 2013, EF6 with CodeFirst, SQL Server 2012

I have tried the four different ways to get the data without any issues.

IQueryable&l         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 13:03

    The main problem I see with your code is the lines like this:

    qryResults.Where(w => w.AL.CompareTo(vbVal) >= 0);
    

    You start with qryResults, compute a .Where(...) but you don't re-assign the query back to qryResults.

    Try this:

    qryResults = qryResults.Where(w => w.AL.CompareTo(vbVal) >= 0);
    

    Although this doesn't explain why you're getting no results back. That'll be a question you should tackle when you get the code right.

提交回复
热议问题