You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Strict data type comparision when using concat results in Unable to translate set operation when matching columns on both sides have different store types
#28528
When concating two queries which have different precise data type (ie. varchar(max) vs varchar(50)) there is exception:
"Unable to translate set operation when matching columns on both sides have different store types.'".
at Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression.ApplySetOperation(SetOperationType setOperationType, SelectExpression select2, Boolean distinct)
at Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression.ApplyUnion(SelectExpression source2, Boolean distinct)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateConcat(ShapedQueryExpression source1, ShapedQueryExpression source2)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Sample.UnitTest.ConcatConstantString() in C:\Projects\Sample\Sample\UnitTest.cs:line 26
Example could be constant value in one query and db column in second, but I would assume same problem can occure when combining queries that are based on different columns:
Panuf
changed the title
Strict data type comparision when using concat
Strict data type comparision when using concat results in Unable to translate set operation when matching columns on both sides have different store types
Jul 27, 2022
When concating two queries which have different precise data type (ie. varchar(max) vs varchar(50)) there is exception:
"Unable to translate set operation when matching columns on both sides have different store types.'".
Example could be constant value in one query and db column in second, but I would assume same problem can occure when combining queries that are based on different columns:
Include provider and version information
EF Core version: 6.0.7
Database provider: SqlServer
Target framework: .NET 6.0
Sample.zip
The text was updated successfully, but these errors were encountered: