-
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
Value comparisons with ToJson() #32160
Comments
For this kind of question, it seems easy to just run a query and see. But in any case, owned entities have identity semantics, which means that two owned entity instances are identical if they're the same one in the database ("reference" comparison rather than structural comparison). This indeed isn't very useful behavior, and is one of the major reasons we're introducing complex types as an alternative modeling. For 8.0 complex type support is still quite limited (e.g. no JSON mapping support), but we intend to expand that support to replace owned entities in many scenarios.
That's a good question.. First, setting facets on a JSON column (including collation) is tracked by #28591. Regarding whether the collation should be binary by default, the collation of the column flows through to fragments of the documented extracted from it. That means that in a query such as
This is definitely not a scenario we currently support; but I'm not sure I see any fundamental difference between this case and the case of a regular string column used as a key. Regardless, I don't think that the regular vs. provider value distinction is meaningful in the context of a JSON column. |
Whiled focused on As a workaround until complex types support |
It's not by default - it's always.
Comparers work at the property level, not at the entity level. EF doesn't compare entities (or complex types) directly to each other, it compares their contained properties one-by-one (as it needs to know which ones changed). |
I have a few questions regarding the equality comparisons of complex value objects mapped with
OwnsOne()
/OwnsMany()
combined withToJson()
.First, how are equality comparisons made? Especially with 8.0's support for non-primitive collections, it seems essential that collections are compared structurally.
Second, since JSON is a case-sensitive format intended for data interchange, shouldn't a binary collation be used for the column? At the very least can the collation be set manually?
Third, what if the column is configured as a key (however unlikely that may be)? Comparisons on key properties are made on the provider value rather than the regular value. Are these string comparisons made as binary/ordinal comparisons?
The text was updated successfully, but these errors were encountered: