LINQ is Generating Extra IS NULL Condition in SQL Statement
问题 I'm writing some LINQ to fetch records based on an email, however, the generated SQL contains an additional IS NULL condition which doesn't need to be there because I am checking the parameter value for null in the code prior to adding the condition to the query. My LINQ code is: if (email != null) { query = query.Where(r => r.Email == email); } The SQL condition generated from this is: (([Extent1].[Email] = @p__linq__0) OR (([Extent1].[Email] IS NULL) AND (@p__linq__0 IS NULL))) The ((