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 hash
and password
defined above this line? It looks like you might have forgetten to add the u.
in your query. If password
was already defined, then you wouldn't see an error, but it would never equal hash
.
Did you mean to write:
var users = rdc.Users.Where(u => u.EmailAddress == emailaddress && u.Password == hash);
^^^
Also, @Mark pointed out that using the ==
operator will show errors that the .Equals
operator might ignore.