public object Get()
{
var queryString = System.Web.HttpContext.Current.Request.QueryString;
var skip = Convert.ToInt32(queryString["$skip"]);
var take = Convert.ToInt32(queryString["$top"]);
string filter = queryString["$filter"];
var data = db.Orders.Take(take).ToList();
if (filter != null)
{
string key;
key = filter.Split(new string[] { "'" }, StringSplitOptions.None)[1];
data= data.Where(fil => fil.CustomerID.Contains(key.ToUpper())).OrderBy(obj=>obj.ShipCity).Distinct().ToList();
}
var count = data.Count;
return new { Items = data.Skip(skip).Take(take), Count = data.Count() };
} |
Thank you Keerthana.
The problem with the solution you provide, is that filtering is going to be done on certain fields. Also what if we use excel like filtering where could be more than one filters on one field?
I don't see any way for simple web api usage. One would be to use .net framework that supports odata but the thing is that plans are the server to be running on linux so no luck :)...
I think I will try urladaptor by modifying the controller.
Thanks for your time anyway.