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

Refactor property info handling, allow keys different from Id property #158

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Commits on Aug 3, 2023

  1. Refactor property info handling, allow keys different from Id property

    - Only treat a property named 'Id' as a key if there is no Key or ExplicitKey property. (fixes DapperLib#140)
      The new behavior allows manually specifying a key (or explicit key) that is different from the 'Id' property. Any usage that would previously have succeeded (not thrown an exception) is unaffected.
    
    - Introduce PropertyInfoWrapper to hold all the relevant information about a type's properties.
    
    - Move logic about selecting a key into the PropertyInfoWrapper so it can be cached as well.
    
    - Use a single ConcurrentDictionary of PropertyInfoWrappers instead of one for each type of property. Thread-safety is preserved because all mutation happens inside a thread-safe Lazy<T>.
    
    - Add `PropertyNamedId` to distinguish this property from those explicitly annotated with a `KeyAttribute`.
    osc-nseguin committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    a2f53a3 View commit details
    Browse the repository at this point in the history
  2. clean diff

    osc-nseguin committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    e349aa9 View commit details
    Browse the repository at this point in the history
  3. Fix compound keys by including the PropertyNamedId by default in KeyP…

    …ropertiesCache
    
    Quick and dirty fix. Let's see if the tests pass.
    osc-nseguin committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    2e543bd View commit details
    Browse the repository at this point in the history
  4. Count the Id property as a KeyProperty again

    This brings the behavior closer to current while preserving the new GetSingleKey<T> behavior. Should fix more tests.
    osc-nseguin committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    c4f01c2 View commit details
    Browse the repository at this point in the history
  5. Remove suspicious use of ==

    woops
    osc-nseguin committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    7178dec View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b994d63 View commit details
    Browse the repository at this point in the history
  7. Remove another suspicious ==

    Woops x3
    osc-nseguin committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    37f8593 View commit details
    Browse the repository at this point in the history
  8. fix it

    osc-nseguin committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    b61b06c View commit details
    Browse the repository at this point in the history