Is there a way to represent summary rows with ODat

2019-09-03 08:32发布

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条回答
做个烂人
2楼-- · 2019-09-03 08:52

You should use ODataQueryOptions i.e

public PageResult<MyReport> Get(ODataQueryOptions<MyReportLine> odataQueryOptions)
查看更多
登录 后发表回答