I am trying to access some data from a SQL Server database using EF Core like this:
var result = _dbContext.FreightStatusUpdate
.Where(w => w.AwbNumber == "049-2154784")
.ToList();
The underlying query that gets generated (in output windows) is
SELECT [m].[ID], [m].[AIRPORT_CODE], [m].[APPOINTMENT_NO], [m].[AWB_NUMBER], [m].[CREATED_BY], [m].[CREATED_DATE], [m].[CUSTOM_STATUS], [m].[TYPE], [m].[UPDATED_BY], [m].[UPDATED_DATE]
FROM [FMG].[FreightStatusUpdate] AS [m]
WHERE [m].[AWB_NUMBER] = N'049-2154784'
All columns in the table (including AWB_NUMBER
) are of type varchar
(not NVarchar
), but N
(Unicode) is prefixed in the WHERE
clause, which is causing a performance hit in the application.
Column is defined like below in the Model.
[Column("AWB_NUMBER")]
public string AwbNumber { get; set; }
How can I avoid this, and query the same information, without Unicode conversion for varchar
types, and keep the nvarchar
as N
(Unicode)?