Skip to content

Commit

Permalink
Fix Linq-to-BsonExpression mapping for nested Linq expressions with s…
Browse files Browse the repository at this point in the history
…ame parameter name
  • Loading branch information
lbnascimento committed Apr 20, 2020
1 parent 09e2141 commit 883a1dc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions LiteDB/Client/Mapper/Linq/LinqExpressionVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class LinqExpressionVisitor : ExpressionVisitor

private readonly BsonMapper _mapper;
private readonly Expression _expr;
private readonly string _rootParameter = null;
private readonly ParameterExpression _rootParameter = null;

private readonly BsonDocument _parameters = new BsonDocument();
private int _paramIndex = 0;
Expand All @@ -51,7 +51,7 @@ public LinqExpressionVisitor(BsonMapper mapper, Expression expr)

if (expr is LambdaExpression lambda)
{
_rootParameter = lambda.Parameters.First().Name;
_rootParameter = lambda.Parameters.First();
}
else
{
Expand Down Expand Up @@ -105,7 +105,7 @@ protected override Expression VisitLambda<T>(Expression<T> node)
/// </summary>
protected override Expression VisitParameter(ParameterExpression node)
{
_builder.Append(node.Name == _rootParameter ? "$" : "@");
_builder.Append(_rootParameter.Equals(node) ? "$" : "@");

return base.VisitParameter(node);
}
Expand Down

1 comment on commit 883a1dc

@lbnascimento
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1638

Please sign in to comment.