Skip to content

Attribute free entity configuration #183

@Wuerike

Description

@Wuerike

In my use case:

  • I wanna keep domain models free of db related annotations
  • I wanna avoid write the same model twice, at domain and at infra (+ annotations)

This is the code I wanna avoid

[Collection("transactions")]
public class SaleDto : Entity
{
    [Field("sale_id")]
    public string SaleId { get; set; }

    [Field("authorization_date")]
    public DateTime AuthorizationDate { get; set; }

}

The default driver support this with BsonClassMap (ref)

  • Class with annotation
public MyClass 
{
    // fields and properties
    [BsonExtraElements]
    public BsonDocument CatchAll { get; set; }
}
  • Equivalent of it but with mapping
BsonClassMap.RegisterClassMap<MyClass>(cm => 
{
    cm.AutoMap();
    cm.MapExtraElementsMember(c => c.CatchAll);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementnew feature or requestup for grabsfeature requires community contribution

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions