-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Milestone
Description
Hi,
I've a very simple Forum entity:
public class Forum
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public virtual List<Post> Posts{ get; set; }
}
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:
var var = "דורון";
var scoops = _context.Forums.Single(x => x.Name == var);
exec sp_executesql N'SELECT TOP(2) [x].[Id], [x].[Description], [x].[Name]
FROM [Forums] AS [x]
WHERE [x].[Name] = @__var_0',N'@__var_0 nvarchar(4000)',@__var_0=N'דורון'
But when I use a string literal:
var scoops = _context.Forums.Single(x => x.Name == "דורון");
EF generates the following SQL:
SELECT TOP(2) [x].[Id], [x].[Description], [x].[Name]
FROM [Forums] AS [x]
WHERE [x].[Name] = 'דורון'
Note that the parameter is treated as VARCHAR instead of NVARCHAR
- Using RC1
- The generated SQL was taken from SQL Server profiler.
Reactions are currently unavailable