Skip to content

Support for strongly typed string keys (Id property)#146

Draft
slewis74 wants to merge 4 commits into
masterfrom
strongly-typed-keys
Draft

Support for strongly typed string keys (Id property)#146
slewis74 wants to merge 4 commits into
masterfrom
strongly-typed-keys

Conversation

@slewis74
Copy link
Copy Markdown
Contributor

@slewis74 slewis74 commented Jun 8, 2021

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 slewis74 changed the title Support for strongly typed keys (Id property) Support for strongly typed string keys (Id property) Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant