當我如下定義我的終點API時,返回所有列,oData $ filter,$ Skip,$ filter正常工作。C#Web API oData過濾器失敗
[EnableQuery]
public IQueryable<MyList> GetMyLists()
{
return db.MyLists;//directly from entity table
}
但是,當我只選擇如下所示的某些列時,oData $ filter,$ Skip,$ filter fail。有任何想法嗎?
public IQueryable<MyResult> GetMyLists()
{
return db.MyLists.Select(x => new MyResult
{
Trade_Name = x.Trade_Name,
price = x.price,
remarks = x.remarks,
Comment = x.Comment,
GenericGroupNumber = x.GenericGroupNumber
});
}
我定義MyResult類如:
public class MyResult
{
public string Trade_Name;
public decimal? price;
public string remarks;
public string Comment;
public string GenericGroupNumber;
}
任何指導是不勝感激。