簡體   English   中英

LINQ 包含基於 Entity Framework Core 3.1 中的多個搜索條件的條件

[英]LINQ Contains condition based on multiple search criteria in Entity Framework Core 3.1

我有一個字符串參數,它根據Split(',')操作的結果分成多個搜索過濾器。 我想 select 標題字段包含任何搜索過濾器的所有實體

我希望以下 LINQ 能夠工作

    string[] filters = param.Split(',');

    var query = await
        (from t in this.Context.Persons
         from f in filters.Where(f => t.Title.Contains(f))
         select t).ToListAsync();

但是執行查詢時出現以下錯誤:

Processing of the LINQ expression 't => __filters_0
    .Where(f => t.Title.Contains(f))' by 'NavigationExpandingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core. 

任何幫助表示贊賞。

我最終在 IQueryable 上實現了一個通用的 LikeAny 擴展方法,如下所述: https://github.com/dotnet/efcore/issues/10834

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM