Elfocrash / Cosmonaut

🌐 A supercharged Azure CosmosDB .NET SDK with ORM support
https://cosmonaut.readthedocs.io
MIT License
342 stars 44 forks source link

Newtonsoft Naming Strategy ignored - LINQ builder uses wrong field names in query #55

Closed cburch-bb closed 5 years ago

cburch-bb commented 5 years ago

The LINQ query builder can run into an issue when you use a class level decorator like:

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class SomeEntity

to manage field names in entities. They will not be picked up so if you build a query like: store.Query().Where(entity => entity.FieldA == "some value").ToList(); it will build a query that looks like: SELECT * FROM c WHERE c.FieldA == "some value" instead of what the json decorater makes the field name: SELECT * FROM c WHERE c.fieldA == "some value"

as a workaround I stopped using that decorator and decorated each field with [JsonProperty("fieldA")] - these get picked up correctly and build the expected query.

Elfocrash commented 5 years ago

Hello @cburch-bb,

It looks like this is a bug with the underlying CosmosDB SDK and not Cosmonaut itself. Cosmonaut doesn't own how the queries are converted. It passes that to the CosmosDB SDK.

I will try to dig deeper and see if there is something I can do to potentially fix that on my end but I am not really confident about that.

cburch-bb commented 5 years ago

Doh that's my mistake, I believe you are right. I forgot this was a wrapper around the CosmosDB SDK. Looks like someone has opened this exact same issue over there: https://github.com/Azure/azure-cosmos-dotnet-v2/issues/638

I'll go ahead and close this, thanks for the great library!