Use camelCase for OData WebAPI query string options? - wcf

I'd like to use camelCase in my OData query like this
/api/posts?$filter=someProperty eq 1
instead of PascalCase like so
/api/posts?$filter=SomeProperty eq 1
Is that possible? (Without changing the casing of my C# classes of course.)

Finally this feature now is supported in Microsoft ASP.NET Web API 2.2 for OData v4.0 v5.4.0. You can install it via nuget Install-Package Microsoft.AspNet.OData -Pre and enable case insensitive:
config.EnableCaseInsensitive(true);
More info here.

No. OData properties are case sensitive. However there is a codeplex issue open to support case insensitive property names for OData queries in web API here. Vote for it if you think it should be supported.

Related

Is it possible to support multiple both camel case and snake case as the naming policy for Json in ASP.NET core 3.1?

My current asp net core project is supporting only camel case. We are adding another external api so client can call it. However, the client has been setup to send it properties as snake case. That results in null value inside our api process. Is there a way to setup our project so that it would support both scenarios camel case and snake case as well ? Thank you

open API spec to Odata raml conversion in mule4

I need to expose the rest API as OData service in Mulesoft. I have the below questions.
Is there an easy way/tool to convert openAPI spec to odata(RAML) to use it in APIKit router in mule4.
How we can define complex datatypes in odata.raml file.
You can use open api APIs directly with the last version of APKit and Studio without any conversions:
https://docs.mulesoft.com/release-notes/platform/oas3
On the other hand I'm not sure if you are trying to use OData. That's a different standard. See the instructions for the OData plugin: https://docs.mulesoft.com/apikit/4.x/creating-an-odata-api-with-apikit
You cant define complex data types in odata.raml, but you can now use apikit for odata 4

how to get a list of dependencies in .net core 3.1?

Here is the problem:
I need to get a list of dependencies and its version if available. I'm using .net core 3.1.
First of all, I thought that I need two things:
1.- a list of assemblies that are referenced in the current assembly at runtime. In order to do that I can use Assembly.GetReferencedAssemblies in Reflection. I am guessing that this will include a list of nuget packages, and the version is easy to get, and of course the .net core package and version.
2.- a list of rest api calls, in this case I don't need the version number as it is not available. In this case I don't have a clue. Is there any way that I can get a dynamic list of rest api calls at runtime? So far, I haven't found anything
Apparently, there is not a class that gets this information. In most of the cases, the api call details are stored somewhere, usually appsettings.json, so retrieve them from here.

What is the purpose of AddFormatterMappings() on Asp.net Core 2

I am evaluating the configuration of a Web API App with Asp.Net Core 2. To configure I know it is better for my project to use .AddMvcCore() rather then use AddMvc() since I don't need Razor as we can see here.
Now, I am not sure if I also need this .AddFormatterMappings(). So my question is what is it for?
You can see from the source code in the MVC GitHub repo that it adds a FormatFilter service into the DI setup. The summary for the FormatFilter class is as follows:
A filter that will use the format value in the route data or query
string to set the content type on an ObjectResult returned from an
action.

Where is .AddDbContext method?

Everywhere it's said to call services.AddDbContext<> method but it is not recognized inside the ConfigureServices(IServiceCollection services) method.
What am I doing wrong?
You have to reference the correct package first, which depends on the EF Core provider you want to use.
Microsoft.EntityFrameworkCore.SqlServer for SQL Server, Microsoft.EntityFrameworkCore.Sqlite for SQLite and Microsoft.EntityFrameworkCore.InMemory for in memory (only for testing).
These are the official out-of-the-box providers. There are also 3rd party providers for PostgreSQL, MySQL, etc. The documentation providers a list of available 3rd party providers here.
Also depending on the provider you may also need to declare a certain namespace. The built-in providers are declared in Microsoft.Extension.DependencyInjection namespace so you need to add a using Microsoft.Extension.DependencyInjection; to the top of your Startup.cs.
Other providers (Oracle's MySQL provider for example) uses MySQL.Data.EntityFrameworkCore.Extensions namespace, so you need to define this using using MySQL.Data.EntityFrameworkCore.Extensions;
Note when actually writing the using you only have to reference Microsoft.EntityFrameworkCore omitting the specific package name. Providing it seems to throw an error.