Matching conventions

Matching conventions

While searching for a match between source and target, MappingGenerator always uses case-insensitive comparison mode. Additionally, all underscore characters are removed from the names before the comparison. To find a best match the following matching strategies are executed in order:

  1. Direct mapping When property/field names match directly:

    target.FirstName = source.FirstName;
    target.LastName = source.LastName;
    
  2. Mapping Method Call-To-Property When method name ends with target name:

    target.Total = source.GetTotal()
    
  3. Flattening with sub-property When the path matches the target name:

    target.UnitId = source.Unit.Id
    
  4. Expanding acronyms

    UserName = u.Name
    
  5. ⭐ Flattening

    When sub-property name matches the target name:

    City = s.MainAddress.City
    

    This strategy is used when the Allow for type flattening option is enabled (available only in paid version).

  6. ⭐ Congruent matching

    Trying to match a source to target as a prefix or suffix like t.X = s.XSuffix)

    City = s.CityValue
    

    This strategy is used when the Allow for congruent matching option is enabled (available only in paid version).