-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 change tracking of non-primitive types #9753
Comments
@dejvid-smth The ability to extend equality checks beyond ".Equals" is something that is not implemented yet. We intended to do it as part of type conversions (#242), since it is often needed then, although it is really a different feature. It's also being tracked as part of type mapping here: #8537 |
Hmm... Unless I'm mistaken Dictionary's |
I don't know how exactly ChangeTracker works but we are just updating the same instance of Dictionary and EntityEntry from ChangeTracker only tracks if we actually change instance so both OriginalValue and CurrentValue are pointing to the same instance of Dictionary and therefore are the same. We would have to somehow make a copy of original Dictionary when EntityEntry's state is set to Unmodified and save that as OriginalValue in EntityEntry so we could later compare OriginalValue with CurrentValue. |
@roji Pretty sure Dictionary just does reference equality on the dictionary instance. @dejvid-smth Correct, the snapshot would need to have a copy of the dictionary. |
Issue #9753 This is primarily focused at allowing providers to generate type mappings for non-primitive type mappings. It can also be used for non-primitive types that are used through value conversions, but #10961 covers adding fluent API for this. Also, this implementation does not attempt to address perf issues, but I added at note to #9422. I'm not happy with the name ValueComparer--we should discuss in API review.
Issue #9753 This is primarily focused at allowing providers to generate type mappings for non-primitive type mappings. It can also be used for non-primitive types that are used through value conversions, but #10961 covers adding fluent API for this. Also, this implementation does not attempt to address perf issues, but I added at note to #9422. I'm not happy with the name ValueComparer--we should discuss in API review.
@roji You will need to generate mappings with the appropriate ValueComparers for the types that Postgres supports. It's not clear to be that a deep snapshot/comparison is always the best choice for this kind of property depending on how it is used, but I think you would know better how people typically use these kinds of properties with Postgres and can therefore make a decision as to which is the appropriate behavior. Let's discuss if I'm missing anything. |
Thanks @ajcvickers! I'll take a look at the relevant types and modify their mappings accordingly for 2.1. I think that for arrays and for hstore (a native For anyone following, I've opened npgsql/efcore.pg#305 for array comprison behavior and npgsql/efcore.pg#306 for hstore. |
Just to report that I've value comparison for hstore seems to work perfectly... I'll be adding comparers to array and other relevant types for 2.1 as well. Thanks! |
@ajcvickers if you're interesting in seeing a complex/interesting comparer implementation, take a look at the array comparer, it will also illustrate some of the issues detailed in #11072. |
ChangeTracker does not detect changes to properties of type Dictionary<,>. In provider for PostgreSQL database database column type hstore is mapped to .net type Dictionary<string,string> but this feature can not be used properly if we do not have change tracking for those properties. One solution would be to use ImmutableDictionary but we want to avoid that.
Steps to reproduce
Further technical details
EF Core version: 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.PostgreSQL
Operating system:
IDE: Visual Studio 2017
The text was updated successfully, but these errors were encountered: