我使用Microsoft.Data.Odata
(5.6)來運行下面的查詢:使用 '任意' 上的IEnumerable <string>中的OData LINQ查詢
IEnumerable<Service> services = context.Services.Expand(ServiceQueryExpansion)
.Where(c =>
(serviceNames.Any(s => s.Equals(
c.ServiceName, StringComparison.OrdinalIgnoreCase))))
serviceNames是IEnumerable的字符串
試圖上面的查詢我獲得以下錯誤:
Error translating Linq expression to URI: The source parameter for the 'Any' method has to be either a navigation or a collection property.
我該如何解決這個問題?
@RowlandShaw從OP * serviceNames是IEnumerable的字符串* – CodingIntrigue
@RowlandShaw的,我很抱歉,但OP實際上是國家這樣做'serviceNames是IEnumerable的string'的。此外,OP表示他們想在問題中使用同樣類型的「Any」。 –
'services'是'IEnumerable'(如我們所見)。 'serviceNames',因爲OP聲稱他已經在範圍之外聲明爲'IEnumerable ' –
CodingIntrigue