问题
I am trying to manually write a Web Api that will serve as an OData feed. I don't need much functionality, just the ability to export data stored within Entity framework to an application such as Power BI. I only need to be able to view, so I was planning on just implementing GET requests.
I currently have a standard web api that returns back properly formatted JSON, but I am having trouble formatting this into something that I can import into Power BI as an OData Feed.
Here's a gist of what I have.
public class Report
{
public string ID { get; set; }
public string Name { get; set; }
public string UserID { get; set; }
...
}
[Route("api/[controller]")]
public class ReportController : Controller
{
...
[HttpGet("GetReports/{userID}")]
public IEnumerable<Report> GetReportsByUser(string userID)
{
return GetAllReportsByUser(userID);
}
...
}
I need something like this to work (obviously won't in the current form)
回答1:
Since you are using ASP.NET Core 1 (aka ASP.NET 5), use the OData vNext package to build your OData service. There is a sample service on Github.
来源:https://stackoverflow.com/questions/36670596/manually-creating-an-odata-feed-in-asp-net-core-using-feed-in-power-bi