Skip to content

Custom mappers #308

@jgwconsulting

Description

@jgwconsulting

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions