Is there a way to represent summary rows with OData?

柔情痞子 提交于 2019-12-11 19:24:40

问题


I'm trying to tack on additional information to the list of items returned from an ODataController's method. The use case is summary rows. So we basically want to return the rows of the report and then also additional info with totals, sub-totals, etc.

So, basically starting with this method:

public PageResult<MyReportLine> Get(ODataQueryOptions odataQueryOptions)

I tried wrapping MyReportLine in MyReport

public class MyReport {
    IEnumerable<MyReportLine> _myReportLines;
    MySummaryRow _mySummaryRow;
}

and then returning this MyReport object.

public PageResult<MyReport> Get(ODataQueryOptions odataQueryOptions)

This approach seemed to mess up all the querying mechanisms because the query supplied in the URI was targeting MyReportLine, but MyReport is the actual class that's exposed. I don't think that the wrapper/summary should be a first-class entity...

Is there a recommended approach to this task?


回答1:


You should use ODataQueryOptions i.e

public PageResult<MyReport> Get(ODataQueryOptions<MyReportLine> odataQueryOptions)


来源:https://stackoverflow.com/questions/16470823/is-there-a-way-to-represent-summary-rows-with-odata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!