方法'Boolean Contains(System.String)'不支持对SQL的转换 [英] Method 'Boolean Contains(System.String)' has no supported translation to SQL

查看:72
本文介绍了方法'Boolean Contains(System.String)'不支持对SQL的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法'Boolean Contains(System.String)'没有支持的SQL转换."

"Method 'Boolean Contains(System.String)' has no supported translation to SQL."

查询是IsQueryable,但这已停止工作:

query is IsQueryable but this stopped working:

foreach (string s in collection1)
{
       if (s.Length > 0)
                {
                    query = query.Where(m => m.collection2.Contains(s));

                }
}

更新:当我使查询可枚举"而不是iqueryable时,它起作用.用linq而不是遍历循环来获得相同结果的方法是什么?

UPDATE: it works when i make query "ienumerable" instead of iqueryable. What would be the way to get same result using linq instead of iterating through loop?

推荐答案

尝试一下:

query = query.Where(m => m.collection2.ToList().Contains(s));
                                       ^^^^^^^^

这篇关于方法'Boolean Contains(System.String)'不支持对SQL的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆