[英]EF Core Contains Concat String
in my .net core service I have a list as follows:在我的 .net 核心服务中,我有一个列表如下:
List<string> list = new(){
110234,
231798,
445978
}
The database table has the following columns: int1(2)
, int(3)
, int3(1)
.数据库表具有以下列:
int1(2)
、 int(3)
、 int3(1)
。 Now I want to query all records where the concat string maches.现在我想查询 concat 字符串匹配的所有记录。 But with following example I get a LINQ/Ef-Core exception that this expression can't be translated:
但是在下面的例子中,我得到了一个无法翻译这个表达式的 LINQ/Ef-Core 异常:
myentities = myentities
.Where(e => list.Contains($"{e.int1.ToString("00")}{e.int2.ToString("000")}{e.int3.ToString("0")}"))
.ToList();
Does anyone has an idea how I can handle that?有谁知道我该如何处理?
The solution suggested from @Svyatoslav Danyliv solved my issue: @Svyatoslav Danyliv 建议的解决方案解决了我的问题:
Use this solution .
使用此解决方案。 I hope it is straightforward how to apply filtering in your case.
我希望如何在您的情况下应用过滤很简单。
query = query.FilterByItems(list, (e, x) => e.Field1 == x.Id1 && e.Field2 == x.Id2, true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.