File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
src/EFCore.MySql/Query/ExpressionVisitors/Internal Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -70,17 +70,19 @@ private Expression VisitMySqlBipolarExpression(MySqlBipolarExpression bipolarExp
7070 var defaultExpression = Visit ( bipolarExpression . DefaultExpression ) ?? QueryCompilationContext . NotTranslatedExpression ;
7171 var alternativeExpression = Visit ( bipolarExpression . AlternativeExpression ) ?? QueryCompilationContext . NotTranslatedExpression ;
7272
73- return defaultExpression != QueryCompilationContext . NotTranslatedExpression
74- // ? alternativeExpression != QueryCompilationContext.NotTranslatedExpression
75- // // ? new MySqlBipolarSqlExpression(
76- // // (SqlExpression)defaultExpression,
77- // // (SqlExpression)alternativeExpression)
78- // ? QueryCompilationContext.NotTranslatedExpression
79- // : (SqlExpression)defaultExpression
80- ? ( SqlExpression ) defaultExpression
81- : alternativeExpression != QueryCompilationContext . NotTranslatedExpression
82- ? ( SqlExpression ) alternativeExpression
83- : QueryCompilationContext . NotTranslatedExpression ;
73+ // Check if the expressions are SqlExpression before casting to avoid InvalidCastException
74+ // with EF Core 10's StructuralTypeReferenceExpression
75+ if ( defaultExpression != QueryCompilationContext . NotTranslatedExpression && defaultExpression is SqlExpression )
76+ {
77+ return defaultExpression ;
78+ }
79+
80+ if ( alternativeExpression != QueryCompilationContext . NotTranslatedExpression && alternativeExpression is SqlExpression )
81+ {
82+ return alternativeExpression ;
83+ }
84+
85+ return QueryCompilationContext . NotTranslatedExpression ;
8486 }
8587
8688 /// <inheritdoc />
You can’t perform that action at this time.
0 commit comments