Skip to content
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

Feature/custom table name mapping #12

Conversation

benmccallum
Copy link
Contributor

Addresses: #9

@dougrday dougrday added this to the 0.2.3-beta milestone Apr 17, 2018
@benmccallum
Copy link
Contributor Author

Let me know if you're happy with this and then I'll do another commit with some documentation added to the readme.

Copy link
Member

@dougrday dougrday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes look great, maybe we can change the TableHelper to a DI'ed service so it shares lifetime management with all the other components/services.

/// <summary>
/// Helper for table related operations.
/// </summary>
public static class TableHelper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should probably be a service that's dependency injected with the rest of the dependencies. Something like:

public class NameService : INameService
{
    public string GetTableName<TEntity>()
    {
    }
}

Then, this class would be dependency injected in the AddDapperGraphQL() extension method.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally up to you. I just followed the pattern you'd used for the PropertyHelper, but I agree it'd be nice to have the flexibility to let others supply their own implementation if need be.

Should we leave the caching up to their implementation or have a base class that can/must be used that does it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change it to a service that's dependency injected. The ParameterHelper is different because it's more a caching interface between .NET and GraphQL -- it doesn't matter who uses it to benefit from the cache, whereas it may matter what database you're connecting to for the TableHelper to perform properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started playing around with this and the problem is all the static methods that create Insert/Query/Delete/Update contexts would need to accept an INameService because it can't be automatically resolved. Potentially this needs a bigger shift to use DI completely to new up these contexts. Have stopped for now as I'd like to hear your thoughts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can take a look over the weekend. Thanks Ben!

Copy link
Contributor Author

@benmccallum benmccallum Apr 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just poking around Dapper.Contrib and I wonder if it's something we can depend on our take advantage of. They do some stuff around table name mapping.

https:/StackExchange/Dapper/blob/f29981a77b27a8b4ae1fdb674a081da2fa2ef19f/Dapper.Contrib/SqlMapperExtensions.cs#L39

https:/StackExchange/Dapper/blob/f29981a77b27a8b4ae1fdb674a081da2fa2ef19f/Dapper.Contrib/SqlMapperExtensions.cs#L283

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like they have a default implementation and then a delegate you can supply to override the default if needed. We could look at an approach like that instead of dependency injection potentially.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Why is it still not merged?
I also want to have an ability to specify table name because the default table name is not always suitable.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to change code to use Dapper.Contrib functionality?

@benmccallum
Copy link
Contributor Author

TODO: look at whether we could/should use this: https://twitter.com/ben_a_adams/status/988951647639531522?s=19

@dougrday dougrday modified the milestones: 0.2.3-beta, 0.3.2-beta, 0.4.0-beta May 18, 2018
@dougrday dougrday modified the milestones: 0.4.0-beta, 0.4.1-beta, 0.4.2-beta Oct 23, 2018
@dougrday dougrday removed this from the 0.4.2-beta milestone Nov 8, 2018
@benmccallum
Copy link
Contributor Author

Hey @Alexcei88,

I started on this and then hit a bit of a roadblock with the changes as @dougrday wanted the naming service to be DI-able but it didn't really fit in well with the existing codebase that wasn't super DI-friendly. I then thought about Dapper.Contrib and what they offer as a solution but didn't go much further than that.

If @dougrday is keen to pick this back up and have a look perhaps he can finish it off for you. Let's see what he says.

@dougrday
Copy link
Member

dougrday commented Mar 7, 2019

I'm moving to a new position at a new company, stay tuned, I should have this reviewed/merged soon once that settles down a bit.

@benmccallum
Copy link
Contributor Author

Gonna close this as it's pretty stale. Will keep my fork around for a while longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants