我有(我认为是 odata 格式)这样的网址:
http://localhost:2282/SSE.Web/History.cshtml?GetData=true&itemId=AKE-00129&pid=1&%24filter=indexof(ItemType%2C%27Attri%27)+ge+0&%24skip=0&%24top=50&%24inlinecount=allpages&_=1325589443808
这里有趣的是 $filter 参数。它的格式为“indexof(ItemType,'Attri') ge 0”
源是一个网格(来自 infragistics 的 iggrid),它在 ItemType 列上使用文本“Attri”进行过滤
我的问题是:映射顶部和跳过参数是微不足道的,但如何进行过滤。我需要解析它并构建自己的 linq,还是有其他方法?
这是我到目前为止的代码:
var skip = int.Parse(Request["$Skip"]);
var top = int.Parse(Request["$top"]);
var filter = Request(["$filter"]);
var db = Database.Open("SSEConnectionString");
var entries = db.Query("select * from eHistory order by timestamp desc")
Json.Write(new { results = entries.Where(????).Skip(skip).Take(top), totalRecCount = entries.Count() }, Response.Output);
谢谢你的帮助!
拉尔西