Nevermore icon indicating copy to clipboard operation
Nevermore copied to clipboard

Support for strongly typed string keys (Id property)

Open slewis74 opened this issue 4 years ago • 0 comments

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)
      1. have a constructor that takes a string for the AllocateId to call (can be internal or public ctor)
      2. 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 ToString to return Value. The places passing the value to a DB Parameter need this because that requires an intrinsic type

TODO: WriteTransaction.AllocateId relies on some reflection that may get expensive at scale, a cache should be added.

slewis74 avatar Jun 08 '21 11:06 slewis74