-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filtering NVARCHAR column is missing "N" when using string literal #4622
Comments
@smitpatel by the way, I tried to SQL inject myself with
But EF escapes the ' even if the parameter is a string literal so it didn't work... 😄 |
@gdoron - Its good to know EF stops SQL injection. 😄 |
@smitpatel Isn't it possible to always treat the string literal as NVARCHAR even if unicode isn't needed just like as when using a string parameter? |
@smitpatel @gdoron From what I remember besides the I think that kind of inference for simple patterns is what we should try to do here. To @gdoron's point I think it is probably a good idea to default to Unicode literals when we can't figure out better. |
What problem does the merge for this solve besides the generated sql being more syntactically correct. |
@mikes-gh it is not just a syntax error, the query won't yield results in case of non Unicode characters. |
Hi,
I've a very simple
Forum
entity:And nothing extra related to Forum in the
OnModelCreating
method.EF correctly generates Name as NVARCHAR(MAX) and filtering with a variable generates the correct SQL:
But when I use a string literal:
EF generates the following SQL:
Note that the parameter is treated as VARCHAR instead of NVARCHAR
The text was updated successfully, but these errors were encountered: