Reputation: 2615
I'm using a linq query in my method. When I step over my linq code my isValid
variable sets to false. When it needs to be true. Why is isValid
getting set to false how can I fix this?
C# code
public void Method()
{
bool isValid = false;
using(Database db = new Database())
{
isValid = (from x in db.TableName
where x.Column_A = "Data_Result" &&
x.Number_Col != 11
select x).Any();
//Value of isValid = false???
}
...
}
SQL Example
SELECT * FROM TableName
WHERE Column_A = 'Data_Result' AND Number_Col <> 11
Result
Upvotes: 0
Views: 537
Reputation: 35075
The code looks good and I suspect, as TheGeneral, that the issue is that you're pointing to the wrong database.
You can verify this by getting the first few rows, top 10 maybe, and compare. Make sure you order by Id
so you get the same results.
db.TableName
.OrderBy(r=>r.Id)
.Top(10);
You could add
.Where( x => x.Column_A == "Data_Result")
etc.
I just noticed that you have a single equal mark in your code x.Column_A = "Data_Result"
. Is this your real code?
Upvotes: 2