Closed
Description
David Straw created an issue — 22nd August 2014, 16:07:48:
The value of a closure variable used in a function call in an expression (ex. in Select) in the NHibernate LINQ provider gets locked in to the value that was present the first time the query gets evaluated.
Reproduction case:
class Repro { private Guid MyFunc(MyType item, Guid closureValue) { return closureValue; } public object Run() { IEnumerable<Guid> result; var closureVariable = Guid.NewGuid(); using (var session = mySessionFactory.OpenSession()) { result = session.Query<MyType>() .Select(x => MyFunc(x, closureVariable)) .ToList(); } Debug.Assert(result.First() == closureVariable); // Works the first time but fails all subsequent times return result; } }
Ricardo Peres added a comment — 22nd August 2014, 17:52:54:
Probably a duplicate of NH-2658.