Odata如何从函数返回匿名类型

时间:2017-12-05 18:30:25

标签: c# function return odata anonymous

我想从Odata驱动程序中的函数返回一个匿名类型。但是我得到了406错误。

这是我在WebApiConfig中的功能:

builder.Function("TestFunction")
                       .Returns<Object>();

这是我在Odata控制器中的方法

[HttpGet]
[ODataRoute("TestFunction")]
public IHttpActionResult TestFunction()
{
    var created = (from RI in db.RequestInstance
                         join RVI in db.RequestVersionInstance on RI.ActualRequestVersionInstanceID equals RVI.RequestVersionInstanceID
                         join RS in db.RequestState on RVI.RequestStateID equals RS.RequestStateID
                         where RI.ClientUserID == userDepartmentId && RVI.RequestStateID == 1
                         group RI by new { RI.RequestInstanceID, RS.Name, RS.Color } into C
                         select new DashBoardFilter()
                         {
                             Name = C.Key.Name,
                             Color = C.Key.Color,
                             Quantity = C.Count()
                         }
           ).Single();
    var select= (from RI in db.RequestInstance
                                     join RVI in db.RequestVersionInstance on RI.ActualRequestVersionInstanceID equals RVI.RequestVersionInstanceID
                                     join RS in db.RequestState on RVI.RequestStateID equals RS.RequestStateID
                                     where RI.ClientUserID == userDepartmentId && RVI.RequestStateID == 2
                                     group RI by new { RI.RequestInstanceID, RS.Name, RS.Color } into C
                                     select new DashBoardFilter()
                                     {
                                         Name = C.Key.Name,
                                         Color = C.Key.Color,
                                         Quantity = C.Count()
                                     }
                       ).Single();
    return Ok(new { Created = created, Select = select});
}

我希望你能帮助我

由于

0 个答案:

没有答案