M
M
Mikhail2016-11-23 12:19:04
C++ / C#
Mikhail, 2016-11-23 12:19:04

Building strange query in linq to db, how to fix?

Linq to DB

return await dbSet.FirstOrDefaultAsync(u => u.Email.ToUpper() == email.ToUpper());

Turns into
FROM [dbo].[Users] AS [Extent1]
    WHERE ((UPPER([Extent1].[Email])) = (UPPER(@p__linq__0))) OR ((UPPER([Extent1].[Email]) IS NULL) AND (UPPER(@p__linq__0) IS NULL))

How to remove or?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2016-11-23
@dmitrievMV

By default, there should be no case sensitivity, and if this was not done intentionally, then there is no need to do ToUpper() .

return await dbSet.FirstOrDefaultAsync(u => u.Email == email);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question