@@ -681,20 +681,27 @@ module internal QueryExpressionTransformer =
681681 match projs with
682682 | [] -> prevLambda, foundparams
683683 | proj:: tail ->
684- let operations =
685- // Full entities don't need to be transferred recursively
686- // but Canonical operation structures cannot be lost.
687- [| for KeyValue( k, v) in foundparams do
688- if k = " " then yield k, v
689- else
690- for colp in v do
691- match colp with
692- | OperationColumn _ -> yield k, v
693- | EntityColumn _ -> () |]
694- foundparams.Clear()
695- operations |> Array.distinct |> Array.iter( fun ( k , v ) -> foundparams.Add( k, v))
696684 let lambda1 , dbparams1 = visitExpression proj prevLambda initDbParam
697- dbparams1 |> Seq.iter( fun k -> foundparams.[ k.Key] <- k.Value )
685+ if dbparams1.Count = 0 then
686+ // This was not a database call projection, there was probably some unrelated extra-wrapping lambda.
687+ // It's safest to keep any previous parameters.
688+ ()
689+ else
690+ let operations =
691+ // Full entities don't need to be transferred recursively
692+ // but Canonical operation structures cannot be lost.
693+ [| for KeyValue( k, v) in foundparams do
694+ if k = " " then yield k, v
695+ else
696+ for colp in v do
697+ match colp with
698+ | OperationColumn _ -> yield k, v
699+ | EntityColumn _ -> () |]
700+
701+ foundparams.Clear()
702+ operations |> Array.distinct |> Array.iter( fun ( k , v ) -> foundparams.Add( k, v))
703+ dbparams1 |> Seq.iter( fun k -> foundparams.[ k.Key] <- k.Value )
704+
698705 composeProjections tail lambda1 foundparams
699706
700707 let generatedMegaLambda , finalParams = composeProjections projs ( Unchecked.defaultof< LambdaExpression>) ( Dictionary< string, ResizeArray< ProjectionParameter>>())
0 commit comments