Skip to content

Commit 1188ca6

Browse files
Merge pull request #1665 from fredericDelaporte/FutureGetEnumerable
Have IFutureEnumerable.GetEnumerable executing immediatly the query
2 parents 61bd921 + 9c0744a commit 1188ca6

File tree

6 files changed

+53
-9
lines changed

6 files changed

+53
-9
lines changed

build-common/NHibernate.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionMajor Condition="'$(VersionMajor)' == ''">5</VersionMajor>
44
<VersionMinor Condition="'$(VersionMinor)' == ''">0</VersionMinor>
5-
<VersionPatch Condition="'$(VersionPatch)' == ''">4</VersionPatch>
5+
<VersionPatch Condition="'$(VersionPatch)' == ''">5</VersionPatch>
66
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>
77

88
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>

build-common/common.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
<!-- This is used only for build folder -->
3232
<!-- TODO: Either remove or refactor to use NHibernate.props -->
33-
<property name="project.version" value="5.0.4" overwrite="false" />
34-
<property name="project.version.numeric" value="5.0.4" overwrite="false" />
33+
<property name="project.version" value="5.0.5" overwrite="false" />
34+
<property name="project.version.numeric" value="5.0.5" overwrite="false" />
3535

3636
<!-- properties used to connect to database for testing -->
3737
<include buildfile="nhibernate-properties.xml" />

releasenotes.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
Build 5.0.4
1+
Build 5.0.5
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.0.5
5+
6+
** Bug
7+
* #1665 Have IFutureEnumerable.GetEnumerable executing immediatly the query
8+
9+
Build 5.0.4
210
=============================
311

412
Release notes - NHibernate - Version 5.0.4

src/NHibernate.Test/Async/Futures/FutureQueryFixture.cs

+20
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,25 @@ public async Task CanExecuteMultipleQueryWithSameParameterNameAsync()
152152
}
153153
}
154154
}
155+
156+
[Test]
157+
public async Task FutureExecutedOnGetEnumerableAsync()
158+
{
159+
Sfi.Statistics.IsStatisticsEnabled = true;
160+
try
161+
{
162+
using (var s = Sfi.OpenSession())
163+
{
164+
var persons = s.CreateQuery("from Person").Future<Person>();
165+
Sfi.Statistics.Clear();
166+
await (persons.GetEnumerableAsync());
167+
Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1));
168+
}
169+
}
170+
finally
171+
{
172+
Sfi.Statistics.IsStatisticsEnabled = false;
173+
}
174+
}
155175
}
156176
}

src/NHibernate.Test/Futures/FutureQueryFixture.cs

+20
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,25 @@ public void CanExecuteMultipleQueryWithSameParameterName()
141141
}
142142
}
143143
}
144+
145+
[Test]
146+
public void FutureExecutedOnGetEnumerable()
147+
{
148+
Sfi.Statistics.IsStatisticsEnabled = true;
149+
try
150+
{
151+
using (var s = Sfi.OpenSession())
152+
{
153+
var persons = s.CreateQuery("from Person").Future<Person>();
154+
Sfi.Statistics.Clear();
155+
persons.GetEnumerable();
156+
Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1));
157+
}
158+
}
159+
finally
160+
{
161+
Sfi.Statistics.IsStatisticsEnabled = false;
162+
}
163+
}
144164
}
145165
}

src/NHibernate/Impl/DelayedEnumerator.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ public DelayedEnumerator(GetResult result, GetResultAsync resultAsync)
2525

2626
public IEnumerable<T> GetEnumerable()
2727
{
28-
var value = _result();
29-
foreach (T item in value)
30-
{
31-
yield return item;
32-
}
28+
return _result();
3329
}
3430

3531
// Remove in 6.0

0 commit comments

Comments
 (0)