locked
Entity Framework Query where value is Null RRS feed

  • Question

  • User1864322503 posted

    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?

    Friday, January 20, 2017 5:22 PM

All replies