I have the following Linq to SQL query.
var users = rdc.Users.Where(u => u.EmailAddress.Equals(emailaddress) && password.Equals(hash));
But it always translates to:
SELECT [t0].[Id], [t0].[Guid], [t0].[RoleId], [t0].[EmailAddress], [t0].[Password], [t0].[FirstName], [t0].[LastName], [t0].[Created], [t0].[Activated], [t0].[LastAction]
FROM [dbo].[Users] AS [t0]
WHERE 0 = 1
I just re-imported the tables into my DBML file to insure that the latest schema is reflected, but it still removes my clause and adds WHERE 0 = 1
I can use ExecuteQuery<T>(string, params[]) but I want to find the root cause of this.
Are
hashandpassworddefined above this line? It looks like you might have forgetten to add theu.in your query. Ifpasswordwas already defined, then you wouldn’t see an error, but it would never equalhash.Did you mean to write:
Also, @Mark pointed out that using the
==operator will show errors that the.Equalsoperator might ignore.