CosmosDB - Entity Framework 核心 - 包含无法翻译

CosmosDB - Entity Framework Core - Contains could not be translated

我尝试使用 entity framework core 3.0 (Microsoft.EntityFrameworkCore.Cosmos 3.0.0) 来操作 CosmosDB (SQL)。

一切正常,除非我尝试使用 ContainsStartWith、...

例如:

var query = _context.Challenges.Where(c => c.Name.Contains( "string"));

EF 应该将其转换为以下 SQL(在 CosmosDB – 查询资源管理器上完美运行)

SELECT * FROM c WHERE CONTAINS(c.Name, "string")

但我收到以下错误信息:

The LINQ expression 'Where<Challenge>(\n    source: DbSet<Challenge>, \n    predicate: (c) => c.Name.Contains(\"string\"))' could not be translated. 
Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). 
See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.

当然,我不想像下面这样写,那样会在客户端执行整个包含,只是为了简单的LIKE...

List<Challenge> entities = _context.Challenges.AsEnumerable().Where(c => c.Name.Contains( "string")).ToList();

有人想过在服务器端评估 "contains" 吗?

注意:我使用 UseSqlServer 而不是 UseCosmos 尝试完全相同的代码(并通过添加所需的 [Key] 注释并创建 SQL 服务器)并且它的工作原理非常棒......所以它是一个明确的 CosmosDB 与 EF 问题。

通过在 entity framework 核心论坛 (https://github.com/aspnet/EntityFrameworkCore/) 上发布相同的问题,得到的答复是此功能尚未实现:

https://github.com/aspnet/EntityFrameworkCore/issues/18673

https://github.com/aspnet/EntityFrameworkCore/issues/16143

https://github.com/aspnet/EntityFrameworkCore/issues/18451

https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/6333414-implement-like-keyword