Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

slewis74
Copy link
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