-
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 Conversion of custom struct type throws exception if it doesn't implement == and != operators #12290
Comments
Note for triage: I was able to repro this. |
Structs cannot use operators |
Fixes #12290 The issue here is that a ValueComparer was not being used when it should have been.
This is approved for 2.1.3. Do not merge yet; branch is expected to open Monday. Given these issues have been parked for some time, please be careful to ensure the correct commits get into the correct branches. |
@ajcvickers This issue is approved for patch and the release\2.1 branch is now open for merging. Please ensure:
|
Getting the same issue with .NET Core 3.0 and EF Core 3.0. Resolution is to implement operators == & != on the struct. Stack trace: |
It seems this issue still exists on MUCH newer versions. I'm running System.InvalidOperationException: The binary operator Equal is not defined for the types 'Disqord.Snowflake' and 'Disqord.Snowflake'.
at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)
at System.Linq.Expressions.Expression.Equal(Expression left, Expression right, Boolean liftToNull, MethodInfo method)
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.BuildPredicate(IReadOnlyList`1 keyProperties, ValueBuffer keyValues, ParameterExpression entityParameter)
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.BuildLambda(IReadOnlyList`1 keyProperties, ValueBuffer keyValues)
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.FindAsync(Object[] keyValues, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.FindAsync(Object[] keyValues) It took a lot of googling but i eventually found this exact issue which seems to be related or maybe the same. Is the only current fix still to define Is this worth re-opening or looking into again? Something seems up here, but it could just be my code. |
@QuantumToasted Please open a new issue and attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
Steps to reproduce
Further technical details
EF Core version: 2.1.0
Database Provider: Microsoft.EntityFrameworkCore.Sqlite
Operating system: Win7
IDE: Visual Studio 2017 15.7.2
The text was updated successfully, but these errors were encountered: