FransBouma / LinqToSQL2

Official Linq to SQL fork. A complete ORM which is backwards compatible with Linq to SQL but with new features.
Other
57 stars 22 forks source link

Add support for entity splitting (multiple entity types, same table row) #20

Open FransBouma opened 9 years ago

FransBouma commented 9 years ago

Entity splitting is sometimes a nice feature if you want to model a part of an entity into another entity. Typical example is to model the Photo field (which is an Image field) in an Employee entity into a separate entity, e.g. EmployeePhoto, with a 1:1 relationship over the PK. This allows the Employee entity to not fetch the Photo field by default, only when the related entity is fetched as well.

The implementation is a little tricky because persisting a new EmployeePhoto entity isn't an insert but an update of an existing row. I.o.w.: the entity type has to be known as a 'split off' entity so the core logic knows to generate an update, not an insert.

(related to #21)