Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flattening of complex (object) properties of an entity #38

Open
8 tasks
satano opened this issue Jul 31, 2019 · 0 comments
Open
8 tasks

Flattening of complex (object) properties of an entity #38

satano opened this issue Jul 31, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@satano
Copy link
Member

satano commented Jul 31, 2019

This is detailed info about Support for complex entities, whose properties are another objects from issue #8.

The goal

We want to load (and save) from database entities with complex properties. Complex property is a property which is another object. In its simplest form, say we have this entity Invoice:

public class Invoice
{
    int Id { get; set; }
    string InvoiceNumber { get; set; }
    Address Supplier{ get; } = new Address();
    Address Purchaser { get; } = new Address();
}

public class Address
{
    public string Street { get; set; }
    public string City { get; set; }
    public string Country{ get; set; }
}

And we want to automatically map it to table with these columns:

  • Id
  • InvoiceNumber
  • SupplierStreet
  • SupplierCity
  • SupplierCountry
  • PurchaserStreet
  • PurchaserCity
  • PurchaserCountry

What/how should work

  • Complex properties with injector set must not be flattened.
  • Column name will be defined as concatenated names of properties:
    Supplier.Street -> SupplierStreet
  • Deep flattening of properties:
    Invoice.Supplier.Address.Street -> SupplierAddressStreet
  • Setting specific column name for nested property:
    .Property(p => p.Supplier.Address.Street).HasColumnName("SupplierStreet")
  • Complex properties can be readonly ({ get; }) or read/write ({ get; set; }).
    • If the property is null, instance should be created automatically if it is possible (property is r/w and property's type has parameterless constructor).
  • Can set nested properties as not mapped:
    .Property(p => p.Supplier.Country).NoMap()
  • Can use injectors for nested properties:
    .Property(p => p.Supplier.Country).InjectValue(...)
  • Update readme.

Other considerations

  • Should flattening work automatically and be turned off if not wanted, or vice versa?
  • We will support only fluent configurations for this (no attributes).
  • Can we make whole attribute configuration obsolete?
@satano satano added the enhancement New feature or request label Jul 31, 2019
@satano satano added this to the Version 4.0.0 milestone Jul 31, 2019
@satano satano self-assigned this Jul 31, 2019
@satano satano changed the title "Flattening" of complex (object) properties of an entity Flattening of complex (object) properties of an entity Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant