AutoQueryable icon indicating copy to clipboard operation
AutoQueryable copied to clipboard

Static mappings

Open skynet2 opened this issue 5 years ago • 2 comments

Hi @trenoncourt ,

Thanks for your awesome library. In the scope of our project, we decided to use it as a replacement for graphql api.

But there is a problem, our system-wide standard is snake case, so all response properties are converted in a snake case using json.net. But in order this library to work we had to pass property name in CamelCase (as we have in c# code).

After some research, we implemented a solution to add an ability to have a static mapping for your library.

We`ve created an entity framework mapping builder which uses attributes from entity framework to correctly map properties.

Can you please take a look at commit https://github.com/skynet2/AutoQueryable/commit/93893110d63943a8d43d287de1a4b67d196e9401

If it`s okay to have in public repo for your library, I can add some tests and create a pull request.

Thanks, Stas

skynet2 avatar Nov 21 '18 17:11 skynet2

hi @skynet2,

Thank you for your interest in AQ. Please use develop branch for pull request, it has the last changes.

Are you going to add a new AutoQueryableSettings to enable/disable snake case ?

I saw no reference to ef package and this is fine because AQ works directly on top of iqueryable to have a maximum of compatibility.

thanks

trenoncourt avatar Nov 21 '18 17:11 trenoncourt

Hi @trenoncourt ,

Okey, i`ll take develop branch.

In fact, snake_case will be supported only by static mapping and entity build (at the current time)

Yep, i don`t want to add a reference to EFCore package, that's why during the creation of static maps I use reflection to take properties, methods from DB context.

============ I have one more question, what do you think about removing such properties as IClauseValueManager ClauseValueManager { get; } IQueryable TotalCountQuery { get; } from IAutoQueryableContext. Im not very familiar with your project yet, but my idea is having AutoQueryableContext as singleton. The reason for this is that im not using asp.net, we build our own rpc protocol on top of RabbitMQ.

Thanks

skynet2 avatar Nov 21 '18 18:11 skynet2