henkmollema / Dommel

CRUD operations with Dapper made simple.
MIT License
611 stars 99 forks source link

DefaultTypeMap.MatchNamesWithUnderscores is not finding columns in snake case #265

Closed xavidram closed 3 years ago

xavidram commented 3 years ago

I initialize the FluentMapper as follows:

DefaultTypeMap.MatchNamesWithUnderscores = true;

FluentMapper.Initialize(config => {
  config.AddMap(new AttendantMapper());
  config.AddMap(new AddressMapper());
  config.AddMap(new PhoneMapper());

  config.ForDommel();
});

The problem is when inserting a model, if one of my columns is defined as BranchId in the class definition but the table column name is branch_id. The MatchNamesWithUnderscores is being overwritten?

When I define the mapper for each column Map(i => i.BranchId).ToColumn("branch_id") the column is found as I have explicitly defined the column map. All the table columns are snake case. Do I need to overrride the MatchNamesWithUnderscores somewhere else so it takes precedence?

xavidram commented 3 years ago

Figured it out using a IColumnResolver.