What is the equivalent of SqlFunctions
in Entity Framework (EF) Core 2.0?
I am trying to convert this to EF Core
private static readonly MethodInfo StringConvertMethodDouble = typeof(SqlFunctions).GetMethod("StringConvert", new Type[] { typeof(double?) });
Edit #1: I should specify that I am generating a dynamic linq query with expression tree to query the database
Thanks
EF Core 6.0 itself is 31% faster executing queries. Heap allocations have been reduced by 43%.
EF Core allows for using user-defined SQL functions in queries. To do that, the functions need to be mapped to a CLR method during model configuration. When translating the LINQ query to SQL, the user-defined function is called instead of the CLR function it has been mapped to.
EF Core does not support the EDMX file format for models. The best option to port these models, is to generate a new code-based model from the database for your application.
EF Core surfaces functions via EF.Functions
, however in 2.0 only Like
is available:
ctx.TestEntities.Any(entity => EF.Functions.Like(entity.Name, "%foo%"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With