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

Custom mappers #308

Open
jgwconsulting opened this issue Oct 6, 2022 · 2 comments
Open

Custom mappers #308

jgwconsulting opened this issue Oct 6, 2022 · 2 comments

Comments

@jgwconsulting
Copy link

I've been looking at creating a custom mapper but the example seems off to me (although it's probably me misunderstanding it!).

public class CustomPluralizedMapper<T> : PluralizedAutoClassMapper<T> where T : class 
{
    public override void Table(string tableName)
    {
        if(tableName.Equals("Person", StringComparison.CurrentCultureIgnoreCase))
        {
            TableName = "Persons";
        }

        base.Table(tableName);
    }
}

The code above appears to set TableName to "Persons" if the original table name is "Person" but it then calls base.Table passing the original tableName.

public virtual void Table(string tableName)
        {
            TableName = tableName;
        }

...which will set TableName back to "Person", won't it? I guess this will still work if the table name is always referenced from the overridden Table method, but it seems a bit odd.

@valfrid-ly
Copy link
Collaborator

valfrid-ly commented Oct 6, 2022

Hi, I'll check this example but, just reading the code, it's seems wrong. tableName should be changed to Persons, not TableName

@jgwconsulting
Copy link
Author

Ah cool, that's what I thought but I'm no stranger to getting things wrong, so I figured I'd check :) Thanks for all your hard work on this super handy project!

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

No branches or pull requests

2 participants