I cannot understand what is wrong with following query:
var tmp = dbset.AsEnumerable<mytable>().Where(
c=>c.Barcode.Contains("11") && c.Description.Contains("EW") );
return tmp;
Should this be same as:
select * from mytable
where Barcode like '%11%' and Description like '%EW%';
If I run this in sql server i get four rows as it should be, but not when I run the linq query
i get 0 rows.
Can please someone help me. It is rather a simple query and it is giving me such a headache. Thank you very much
Don’t do that!
You are causing all your data to get pulled from the database before checking the
Wherecondition.Other than that, it’s not really clear why your query isn’t working. Your syntax is correct. I’m guessing the data doesn’t actually look like you think it does. Either that, or you’re expecting
like %EW%to match something in a case-insensitive manner and since the Where clause is being evaluated by LINQ to Objects you’re not getting that behavior.