-
Notifications
You must be signed in to change notification settings - Fork 99
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
Why a hard reference to the column "id" #140
Comments
agreed, i've been bitten by this |
Because that's how EntityFramework does it by default and drop-in replacement had to follow this convention, regardless of our personal opinions :) We'd need something similar to EF ModelBuilder Custom Conventions to override default behavior. However with Dapper.Contrib being just a bunch of extension methods to |
I agree that if you are not told a key and have an ID column, ID is a reasonable guess. |
That might trip over case where there is compound Key using that implicit Id column. If suddenly Id will stop being detected update might introduce breaking bug to existing projects. Maybe |
my use case is any integration with microsoft dynamics ; the primary key for entity X is always XId. it's a guid allocated by the system. |
- 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`.
Why a hard reference to the column "id" on line 112 in below code?:
Dapper.Contrib/src/Dapper.Contrib/SqlMapperExtensions.cs
Line 112 in cf24f6b
Even when this column is NOT in an index.....
The text was updated successfully, but these errors were encountered: