I am experiencing a very slow performance when I set a string variable in my EF Where clause and very fast performance when I hard code the string value in the where clause.
C#, .Net Framework 4.7.1, EF 6.2
db.Dealers.Where(x => x.SourceDealerId == "000111222fff333q");
var parameter = "000111222fff333q"; db.Dealers.Where(x => x.SourceDealerId== parameter );
There is difference in the SQL that is generated in both cases.
For the fast case:
WHERE dealerId = '000111222fff333q'
For the slow case:
This might be related to NULL comparison setting in Entity Framework
add the following code before your query to see if it helps your query performance:
context.ContextOptions.UseCSharpNullComparisonBehavior = false;
- Do I need to add \0 to the end of a string literal being passed into a function?
- My consoleHandler does not handle CTRL+C even though properly set
- Under what circumstances would one use a signed char in C++?
- Cannot forward() a net using Openvino Intermediate Representation Files, but can use ONNX file I am making an IR of
- Qt video streaming application: no service found for qt.mediaplayer
- There is a way to register service which is given as implicit type and has constructor with more then one parameter of primitive type
- Keep the duplicated values only - Vectors C++
- How does KDE Konsole handle a SIGTERM?
- Is longjmp supposed to restore the stack?
- how I can create a list of rows of double[,]