nhibernate/nhibernate-core — pull request #54 by hazzik (2012-01-12 06:10:46+00:00)
Title: NH-3009: Linq trying to add parameters twice if same predicate is used in query more then once

```
Expression> predicate = timesheet => timesheet.Entries.Any(e => e.Id != 1);

var query = db.Timesheets
.Where(predicate)
.Where(predicate) // don't ask why I need this
.ToList();
```

This query throws exception

```
System.ArgumentException : An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at NHibernate.Linq.Visitors.ExpressionParameterVisitor.VisitConstantExpression(ConstantExpression expression) in ExpressionParameterVisitor.cs: line 43
...
at NHibernate.Linq.Visitors.ExpressionParameterVisitor.Visit(Expression expression) in ExpressionParameterVisitor.cs: line 21
at NHibernate.Linq.NhLinqExpression..ctor(Expression expression) in NhLinqExpression.cs: line 35
at NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, ref IQuery query, ref NhLinqExpression nhQuery) in DefaultQueryProvider.cs: line 67
at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) in DefaultQueryProvider.cs: line 33
at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) in DefaultQueryProvider.cs: line 40
at Remotion.Linq.QueryableBase`1.GetEnumerator() in c:\build\Remotion\working\Relinq\Core\QueryableBase.cs: line 132
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList(IEnumerable`1 source)
```

JIRA: https://nhibernate.jira.com/browse/NH-3009