bchavez / RethinkDb.Driver

:headphones: A NoSQL C#/.NET RethinkDB database driver with 100% ReQL API coverage.
http://rethinkdb.com/api/java
Other
383 stars 134 forks source link

Linq provider does not support custom property naming conventions. #125

Closed roald-di closed 6 years ago

roald-di commented 6 years ago

I am using snake_case_property_names in my rethinkdb tables.

While it is possible to configure the serializer to read the records in this format, it's not possible to generate queries with the linq provider that follow the same naming convention.

So for example running .Where(user => user.FirstName == "John") will result in a query with a filter containing "FirstName" instead of "first_name".

The name used in the query is determined here: https://github.com/bchavez/RethinkDb.Driver/blob/059c7e9aedf0fb81d480ec5a3594c7ab29d22611/Source/RethinkDb.Driver.Linq/MemberNameResolver.cs#L28 I think that maybe this could be extended to get the name from the ContractResolver configured on RethinkDb.Driver.Net.Converter.Serializer or the JsonPropertyAttribute if present.

However I'm not sure if introducing another dependency on Newtosoft.Json is a good idea given this issue: https://github.com/bchavez/RethinkDb.Driver/issues/33

I am willing to work on a PR if I can get some guidance on the design.

bchavez commented 6 years ago

Hi @roald-di,

Thank you for spending time identifying the issue with the appropriate details. I really appreciate it.

You're correct, adding another dependency on Newtonsoft.Json might not be the best way for reasons like #33 but also the added maintenance of keeping Newtonsoft.Json version numbers in sync.

As far as guidance goes:

I think this approach avoids taking a hard dependency on Newtonsoft.Json all over again in the Linq NuGet package and keeps the dependency graph as-is with the least impact.

I'm also open to other ideas, but that's how I would start. Let me know what you think.

Hope that helps, Brian

PS. Protip: Run build restore first before opening up the VS solution.

:boom: :fire: "Set it ablaze like a candle wick... Light it up, light it up..."