Closure variable values locked in from expressions in NHibernate LINQ provider

Description

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; } }

Environment

None

Activity

Show:

Frédéric Delaporte January 18, 2018 at 6:02 PM

Moved here.

Ricardo Peres August 22, 2014 at 5:52 PM

Probably a duplicate of NH-2658.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?

Created August 22, 2014 at 4:07 PM
Updated January 20, 2018 at 10:43 PM
Resolved January 20, 2018 at 10:42 PM
Who's Looking?