我在那裏,我想通過ID列表過濾OData服務;在SQL相當於將是這樣的:的OData「其中列表ID」查詢
SELECT * FROM MyTable WHERE TableId IN (100, 200, 300, 400)
我想過濾的屬性類型爲一個Int32。我試過以下,這給了我一個錯誤「操作員‘添加’不兼容的操作數類型‘Edm.String’和‘Edm.Int32’」:
string ids = ",100,200,300,400,";
from m in provider.Media where ids.Contains("," + t.media_id + ",")
以及
string ids = ",100,200,300,400,";
from m in provider.Media where ids.Contains("," + t.media_id.ToString() + ",")
和
string ids = ",100,200,300,400,";
from m in provider.Media where ids.Contains("," + Convert.ToString(t.media_id) + ",")
和
string ids = ",100,200,300,400,";
from m in provider.Media where ids.Contains(string.Concat(",", t.media_id, ","))
如您所見,目前我正在使用LINQ來查詢服務。
有沒有一種方法可以做我想做的事,或者我堅持構造一個文本過濾器並使用AddQueryOption,並遍歷列表並手動添加「or media_id eq 100」子句?
https://gist.github.com/mausch/6893533 –