Using Microsoft.AspNetCOre.OData 7.0.1
, if I have a list of Models that are NOT in the database, the JSON result always comes back as PascalCase instead of camelCase. How can I get my list to be camelCase?
Relative example below:
My model that is NOT in the database.
public class Widget
{
public string Id { get; set; }
public string Name { get; set; }
}
My controller
[Route("api/[controller]")]
public class WidgetController : ODataController
{
[EnableQuery()]
public IActionResult GetWidgets()
{
// Create list of ten Widgets
var widgetsList = new List<Widget>();
for(var i = 0; i < 10; i++) {
widgetsList.Add(new Widget() { Id = i, Name = $"Widget {i}" });
}
return this.Ok(widgetsList);
}
}
/api/GetWidgets?$select=name returns in the following format
{ Name: "Widget" }