Hi!
.net 461, MSSQL 13.0.5081.1
We migrated from 4.1 LLBLGen to 5.6.1 RTM
following code worked in 4.1
var programIds = Enumerable.Range(1, 20).ToArray();
var activityTypeId = 1;
var templateId = 2;
var activityPrograms = CreateLinqMetaData().ActivityAttachment
.Where(aa => aa.Activity.ActivityTypeId == activityTypeId
&& aa.Document.TemplateId = templateId)
.Select(aa => aa.Activity.ProgramId);
var programExists = activityPrograms.Any(pid => programIds.Contains(pid));
but throw exception in 5.6.1
Please, help us understand why an exception is thrown.
Is it bug in our code or in LLBLGen?
exception:
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryConstructionException: Unexpected operand '531' of in-clause expression: '[531]'. Did you pass an in-memory method call to an in-memory Contains() method?
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleInClauseExpression(InClauseExpression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleLambdaExpression(LambdaExpression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleAllAnyExpression(AllAnyExpression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleProjectionExpression(ProjectionExpression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleSelectExpression(SelectExpression expressionToHandle, SelectExpression newInstance)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleSelectExpression(SelectExpression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleSelectExpression(SelectExpression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.HandleExpressionTree(Expression expression)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at
P.S.
We have 2 working workarounds
1. Add .ToArray() to .Select(aa => aa.Activity.ProgramId)
2. move Contains to Where\Any
var programExists = CreateLinqMetaData().ActivityAttachment
.Any(aa => aa.Activity.ActivityTypeId == activityTypeId
&& aa.Document.TemplateId = templateId
&& programIds.Contains(aa.Activity.ProgramId));