我有以下课程:
public class WeeklyReport
{
public IEnumerable<DailyReport> DailyReports { get; set; }
public int? TotalReport
{
get
{
return DailyReports.Sum(x => x.ReportId);
}
}
public string Title
{
get
{
return "Weekly Report";
}
}
}
public class DailyReport
{
public string Office { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public string ReportTo { get; set; }
public DateTime Collection { get; set; }
public int? Leads { get; set; }
}
在OData控制器中的一个方法中,我返回WeeklyReport的IQueryable。
然而,当查询OData端点时,返回的JSON类似于:
{
"odata.metadata": "http://localhost:546/odata/$metadata#WeeklyReports",
"value": [
{
"DailyReports": [
{
"Office": "002",
"Name": "First Last",
"Type": 10,
"ReportTo": "00002",
"Collection": "2014-03-18T00:00:00",
"Leads": null
},
{
"Office": "002",
"Name": "Agent, ",
"Type": 10,
"ReportTo": "00002",
"Collection": "2014-03-18T00:00:00",
"Leads": null
}
]
},
{
"DailyReports": [
{
"Office": "002",
"Name": "First Last",
"Type": 10,
"ReportTo": "00002",
"Collection": "2014-03-18T00:00:00",
"Leads": null
},
{
"Office": "002",
"Name": "Agent, ",
"Type": 10,
"ReportTo": "00002",
"Collection": "2014-03-18T00:00:00",
"Leads": null
}
]
}
]
是否有方法将ASP.NET Web API OData设置为同时返回WeeklyReport.TotalReport和WeeklyReport.Title?
谢谢