Nevermore
Nevermore copied to clipboard
Support for strongly typed string keys (Id property)
This is a draft for discussion around the concept of supporting strongly typed keys (e.g. TinyTypes).
Nevermore already has support for these types in most columns, through the use of Type Handlers. This investigation was around working out what it might take to support their use as an Id.
The end result has been minimially invasive to Nevermore, and should require no further configuration by consumers.
The core implementation changes of interest were to the following classes:
- ReadTransaction
- WriteTransaction
- DataModificationQueryBuilder
Implementation Assumptions:
- whatever strongly typed string implementation you chose to use, it has to have the following traits
- it must either (see WriteTransaction)
- have a constructor that takes a string for the AllocateId to call (can be internal or public ctor)
- have a default constructor and a settable string property (doesn't matter the name, AllocateId looks for the first one that matches)
- it must implement
ToStringto returnValue. The places passing the value to a DB Parameter need this because that requires an intrinsic type
- it must either (see WriteTransaction)
TODO:
WriteTransaction.AllocateId relies on some reflection that may get expensive at scale, a cache should be added.