Is not null in EntityFramework query

c#-4.0 entity-framework linq-to-entities

Question

Entity Framework 4.0 code first, C# 4.0. What is wrong for is not null in the code?

var query = from c in dbContext.table 
where c.FacilityID == facilityID && c.FilePath is Not null select c;

EDIT:

Many errors after adding is not null.

One of them is :

The type or namespace name 'Not' could not be found (are you missing a using directive or an assembly reference?)

1
6
8/4/2016 8:54:27 AM

Popular Answer

Not is not a keyword in LINQ queries, so you will get the compiler errors. You need to use the inequality operator (!=) to check if FilePath is not null.

The code below should work for you

var query = from c in dbContext.table 
where c.FacilityID == facilityID && c.FilePath != null select c;
11
1/29/2013 8:51:38 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow