EF Core中等效的SqlFunction

Zul*_*der 12 c# entity-framework .net-core

SqlFunctions实体框架(EF)Cor​​e 2.0中的等价物是什么?

我试图将其转换为EF Core

private static readonly MethodInfo StringConvertMethodDouble = typeof(SqlFunctions).GetMethod("StringConvert", new Type[] { typeof(double?) });
Run Code Online (Sandbox Code Playgroud)

编辑#1: 我应该指定我使用表达式树生成动态linq查询来查询数据库

谢谢

Mar*_*ich 11

EF Core表面功能通过EF.Functions,但仅在2.0 Like中可用:

ctx.TestEntities.Any(entity => EF.Functions.Like(entity.Name, "%foo%"))
Run Code Online (Sandbox Code Playgroud)

  • 这根本没有帮助这个特殊问题. (6认同)
  • @alexb 这是正确的答案。`EF.Functions` 或者更确切地说,它返回的 [DbFunctions](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbfunctions?view=efcore-2.1) 实例*是*相当于 SqlFunctions。在 EF Core 2.1 中,大多数功能都可用 (2认同)