我有一个字典,我想在SQL查询中像IN子句一样使用它。
例如。
bool result = DataContext.Table.Any(res => MyDictionary.ContainsKey(res.field1));
实际上,这与
exists(select * from Table where field1 in (select id from DictionaryKeys))
哪里
DictionaryKeys
不幸的是我
System.NotSupportedException was unhandled
Message="Method 'Boolean ContainsKey(System.String)' has no supported translation to SQL."
Source="System.Data.Linq"
我理解这个错误,但我正在努力思考如何解决这个问题。
编辑:
我正在连接到SQL 2005。看来这是一个连接提供者的问题,因为马克的建议翻译成一个列表不适合我。
有什么想法吗?