asp.net-coreuppercasesnakecasing

ASP NET Dataset Column name format


I have an ASP.Net Core 3.1 project which serves APIs.

Some of my apis interact with an Oracle DB, to get some dataset

Here is a short example of what one of my api does:

    [HttpGet]
    [Route("api/GetMySpecificData")]
    public IActionResult getData()
    {
        ...
        var ds = new DataSet();
        OracleDataAdapter adapter = new OracleDataAdapter(query, connection);
        adapter.Fill(ds);
        return Ok(ds.Tables[0]);
    }

In my Oracle DB, column names are UPPER_SNAKE_CASED and I expect my Api to return the Dataset with the same format for the property names. (Example : USER_ID). Instead my client receives a different format for column names : useR_ID.

I don't know at all how to fix this, but what I want is to receive property names with the same format that it is set in the DB Column Name

I use this piece of code in my startup.cs ConfigureServices function :

services.AddControllers().AddNewtonsoftJson()

Maybe I have to add some options to specify this behaviour but I have no idea.


Solution

  • I think what I need is maybe to make Newtonsoft.Json case sensitive.

    What I ended up to do is the following :

            services.AddControllers().AddNewtonsoftJson( options =>
            {
                options.UseMemberCasing();
            });