11

我可以执行以下操作:

container.Users.Where(u => u.Name == "Omar").FirstOrDefault()

container.Users.FirstOrDefault(u => u.Name == "Omar")

返回一个NotSupportedException (The method 'FirstOrDefault' is not supported.)

既然这些本质上是一样的,为什么不支持呢?

4

1 回答 1

13

The LINQ Translation engine used by the OData provider doesn't handle every scenario.

While these are logically the same, the expression for each must be generated to build the query string. The engine doesn't support the second form.

于 2013-04-26T16:05:44.127 回答