Linq Contains()不支持

时间:2013-03-15 15:54:21

标签: c# linq entity-framework entity

(from a in GetCtx().Application
                     where identifiers.Contains(a.os + ":" + a.osIdentifier)
                     select a.id).ToList();

它给了我NotSupportedException:

  

LINQ to Entities无法识别方法' System.String   格式(System.String,System.Object,System.Object)'方法,这个   方法无法转换为商店表达式。

谁能告诉我如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

如果对SQL Server使用LINQ to Entities,则可以使用SqlFunctions

(from a in GetCtx().Application
 where identifiers.Contains(SqlFunctions.StringConvert((double)a.os) + ":" + a.osIdentifier)
 select a.id).ToList();