-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support [JsonPropertyName] in query translation #1419
Comments
Can you explain a bit more what you're asking exactly? Would would like an attribute for? |
This query translates to the following: SELECT c."Code", c."Name"->>'En' AS "En" where For example public class Name
{
public string De {get; set; }
[JsonPropertyName("anotherName")]
public string En {get; set; }
} will generate SELECT c."Code", c."Name"->>'anotherName' AS "En" |
same issue |
/cc @lauxjpn |
Hi @roji I'm facing the same issue, if it is already fixed is there any settings to apply? |
@sreejith-ms this was done for 5.0.0, so [JsonPropertyName] is respected there. We generally don't backport new features to patch versions of already-released versions (like 3.1). |
@roji I upgraded the versions and tested, but the issue still exists. Npgsql.EntityFrameworkCore.PostgreSQL: 5.0.2
|
@sreejith-ms can you please post a runnable code sample? |
@roji The issue is resolved when I removed
|
@sreejith-ms although Json.NET is supported at the ADO.NET level (as in the docs), at the EF Core provider level only System.Text.Json is supported. So I'm not sure why you're seeing that specific issue and why it occurs only with UseJsonNet, but UseJsonNet should not be specified in an EF Core application. |
I just checked the code for Pomelo, but it looks like we had already implemented it for both System.Text.Json (MySqlJsonNewtonsoftPocoTranslator.cs) and Json.NET (MySqlJsonMicrosoftPocoTranslator.cs). |
@sreejith-ms there haven't been any requests up to now for Json.NET support at the EFCore.PG level - this is the first time - most people seem to be OK with System.Text.Json. Note that S.T.J is also fully supported at the ADO.NET level (without any plugins), so you can switch to that at the ADO.NET level as well - the transition from Json.NET to S.T.J could be trivial, depending on exactly which features of Json.NET you're using. |
@sreejith-ms I believe that Pomelo is the only major provider that currently has Json.NET support. However, when it comes to features, a number of missing common ones have been added to S.T.J with .NET 5, which closes the gap between Json.NET and S.T.J to some degree. |
I have following POCO and a
jsonb
field in a DBif I query it this way I have
null
in myEn
field in a resultSo I need either change a property name, either a field key to get a non-nullable value. But could I use an attribute instead?
The text was updated successfully, but these errors were encountered: