demigor/lex.db — pull request #1 by ibebbs (2012-12-28 11:28:10+00:00)
Title: Persistence of Plain Old CLR Interfaces (POCI)

It is often desirable to allow the persistence of a data contract (i.e.
an interface) rather than a specific object. This allows components in
higher layers of the architecture to natively supply instances for
persistence without the persistence layer needing to map into the
underlying persistent ttype.

Given Lex.Db's excellent mapping and persistence mechanisms, it was very
easy to allow this useage scenario through the provision of
InterfaceMap -> DbTable classes.
These classes are synonymous to the TypeMap -> DbTable but exposes
instances as a interfaces and uses the concrete TType (which must
implement TInterface) parameter merely for reading instances from the
store.

NOTES: InterfaceMap copies large swathes of
TypeMap. It would probably be possible to push a lot of the copied
code into a base class (TypeMapBase?) to limit the duplication.

Tests for interface based persistence were copied from the existing
class based persistence and pass successfully.