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

Allow Dapper users to specify custom default type maps #132

Closed
wants to merge 4 commits into from

Conversation

devinlyons
Copy link

Edit: this pull request originated as a way to allow SNAKE_CASE in column names but has evolved into a way to allow users to specify custom default mappers.

This allows DefaultTypeMap to search for columns that use "_" to separate words as an alternative to camel case. Some older database systems, such as DB2 for iSeries only return columns in all caps. This make camel case difficult to deal with during development.

@denniskovshov
Copy link

@ragnarok111 you have ability to create custom mappers in your code so this should not be in the default mapper and not in the main branch. Just create a custom mapper in your code and register it with Dapper.

@devinlyons
Copy link
Author

That is exactly what I would like to do. However, I cannot find any documentation on how to do that unless I want to write a custom mapper for every single type I am pulling from the database. Since most of my types come from a snake case database, I would like to be able to register a single mapper that will handle all of them and fall back to the default mapper. Or it could start with the default mapper and fall back to a custom one.

Can you point me to any documentation on creating custom mappers?

@devinlyons
Copy link
Author

Okay, I have changed my focus on this. I reverted my last change and added a new commit that will allow Dapper to use custom default type mappers that can fall back to the DefaultTypeMap. I added comments to the Commit to explain why I did things the way I did as well as an example mapper.

@devinlyons devinlyons changed the title Allow Dapper to work with Snake Case columns. Allow Dapper users to specify custom default type maps Jul 24, 2014
@socsieng
Copy link

socsieng commented Oct 3, 2014

What are the chances of this being merged?

@mgravell
Copy link
Member

mgravell commented Oct 3, 2014

I simply need to have the time to go through it; I have finite resources, and lots of plates to keep spinning. The contribution is appreciated - I simply haven't had the time to review it or properly think about all the scenarios.

@socsieng
Copy link

socsieng commented Oct 3, 2014

I completely understand. Thanks for the reply.

@fmmsilva
Copy link

fmmsilva commented Oct 5, 2014

I hope this functionality works well, I also work with some snake case databases.

@devinlyons
Copy link
Author

@mgravell, if I rewrite this for this current version of Dapper, would there be a chance it would get merged?

@NickCraver
Copy link
Member

This is going in, but via a simpler implementation in #110. I really do appreciate the commit, the public/virtual bits especially are something we need to discuss. I think exposing the DefaultTypeMap as a base may be something that's reusable. However, the IL bits still need addressing, and I left a note on this in the other PR - we'll take a look before merging in and introducing unexpected behavior.

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

Successfully merging this pull request may close these issues.

None yet

6 participants