Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Entity Framework Query where value is Null

$
0
0

Hello,

I am connecting to an Oracle Database, I am having difficulties with queries where the value being filtered IS NULL.

Typically in Oracle, it would be written as...

select * from table
where myNullableColumn is null;

My query in linq is...

var query = db.SRS_ADD_TO_BOM.Where(b =>
                                                    b.CLIENT_ID.Equals(clientID) &&
                                                    b.STORENUMBER.Equals(storeNumber) &&
                                                    b.EXPIRED.Equals("N"));

the variable storeNumber is null. This query isn't translating into an Oracle query properly.

This is the query generated:

SELECT"Extent1"."SEQ_ID" AS "SEQ_ID","Extent1"."CLIENT_ID" AS "CLIENT_ID","Extent1"."STORENUMBER" AS "STORENUMBER","Extent1"."EXPIRED" AS "EXPIRED"
FROM "VBADMIN"."SRS_ADD_TO_BOM" "Extent1"
WHERE (("Extent1"."CLIENT_ID" = :p__linq__0)
AND ("Extent1"."STORENUMBER" = :p__linq__1) /* <------- "=" cannot be used for null, must be "is" */
AND ('N' = "Extent1"."EXPIRED"));

Is there a way for me to better write my Linq Query so that this works?


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>