Skip to content

Merge Fluent Interface and AutoMap  #75

@jagregory

Description

@jagregory

Merge the Fluent Interface and AutoMappings into one awesome mapping.

What I envision is inspired by StructureMap. Something like the PersistenceModel is equatable to the Repository in StructureMap, where you supply it with mappings (analogous to types). Mappings can be supplied either as instances (or by type) or they can be automapped (analogous to Scanning).

public class MyPersistenceModel : PersistenceModel
{
  protected override void Initialise()
  {
    ForType<Person>
      .UseMapping<PersonMap>();

    ForTypes
      .InNamespace("My.Entities")
      .UseMappingsInNamespace("My.Mappings");

    ForTypes
      .InNamespace("My.SimpleEntities")
      .AutoMap();

    ForType<Product>
      .AutoMap();
  }
}

public class PersonMap : ClassMap<Person>
{
  protected override Initialise()
  {
    DiscoverDefaults();

    Map(x => x.Name)
      .ColumnName("PersonName");
  }
}

This ticket should be separated closer to the time of development!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions