为什么这会抛出System.NotSupportedException?
string foo(string f) { return f; }
string bar = "";
var item = (from f in myEntities.Beer
where f.BeerName == foo(bar)
select f).FirstOrDefault();
编辑:这是一个MSDN 参考,它(有点)解释了一些事情......
LINQ to Entities 查询中未显式映射到规范函数的任何方法调用都将导致引发运行时 NotSupportedException 异常。有关映射到规范函数的 CLR 方法的列表,请参阅 CLR 方法到规范函数的映射。
另请参阅http://mosesofegypt.net/post/LINQ-to-Entities-what-is-not-supported.aspx