You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
list=s.Find("from Baz baz left outer join fetch baz.FooToGlarch");
1773
1773
1774
1774
list=s.Find("select foo, bar from Foo foo left outer join foo.TheFoo bar where foo = ?",
1775
1775
foo,
1776
-
NHibernate.Entity(typeof(Foo))
1776
+
NHibernateUtil.Entity(typeof(Foo))
1777
1777
);
1778
1778
1779
1779
object[]row1=(object[])list[0];
@@ -1837,7 +1837,7 @@ public void Query()
1837
1837
if(!(dialectisDialect.MySQLDialect))
1838
1838
{
1839
1839
// add an !InterbaseDialect wrapper around list and assert
1840
-
list=s.Find("from foo in class NHibernate.DomainModel.Foo where ? = some foo.Component.ImportantDates.elements",newDateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day),NHibernate.DateTime);
1840
+
list=s.Find("from foo in class NHibernate.DomainModel.Foo where ? = some foo.Component.ImportantDates.elements",newDateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day),NHibernateUtil.DateTime);
1841
1841
Assert.AreEqual(2,list.Count,"componenet query");
1842
1842
}
1843
1843
@@ -2061,7 +2061,7 @@ public void Enumerable()
2061
2061
s=sessions.OpenSession();
2062
2062
2063
2063
Assert.AreEqual(8,
2064
-
s.Delete("from q in class NHibernate.DomainModel.Qux where q.Stuff=?","foo",NHibernate.String),
2064
+
s.Delete("from q in class NHibernate.DomainModel.Qux where q.Stuff=?","foo",NHibernateUtil.String),
2065
2065
"delete by query");
2066
2066
2067
2067
s.Flush();
@@ -2076,6 +2076,66 @@ public void Enumerable()
2076
2076
2077
2077
}
2078
2078
2079
+
/// <summary>
2080
+
/// Adding a test to verify that a database action can occur in the
2081
+
/// middle of an Enumeration. Under certain conditions an open
2082
+
/// DataReader can be kept open and cause anyother action to fail.
2083
+
/// </summary>
2084
+
[Test]
2085
+
publicvoidEnumerableDisposable()
2086
+
{
2087
+
// this test used to be called Iterators()
2088
+
2089
+
ISessions=sessions.OpenSession();
2090
+
for(inti=0;i<10;i++)
2091
+
{
2092
+
Simplesimple=newSimple();
2093
+
simple.Count=i;
2094
+
s.Save(simple,i);
2095
+
Assert.IsNotNull(simple,"simple is not null");
2096
+
}
2097
+
s.Flush();
2098
+
s.Close();
2099
+
2100
+
s=sessions.OpenSession();
2101
+
ITransactiont=s.BeginTransaction();
2102
+
Simplesimp=(Simple)s.Load(typeof(Simple),8);
2103
+
2104
+
// the reader under the enum has to still be a SqlDataReader (subst db name here) and
2105
+
// can't be a NDataReader - the best way to get this result is to query on just a property
2106
+
// of an object. If the query is "from Simple as s" then it will be converted to a NDataReader
2107
+
// on the MoveNext so it can get the object from the id - thus needing another open DataReader so
2108
+
// it must convert to an NDataReader.
2109
+
IEnumerableenumer=s.Enumerable("select s.Count from Simple as s");
2110
+
//int count = 0;
2111
+
foreach(objectobjinenumer)
2112
+
{
2113
+
if((int)obj==7)
2114
+
{
2115
+
break;
2116
+
}
2117
+
}
2118
+
2119
+
// if Enumerable doesn't implement Dispose() then the test fails on this line
2120
+
t.Commit();
2121
+
s.Close();
2122
+
2123
+
s=sessions.OpenSession();
2124
+
Assert.AreEqual(10,
2125
+
s.Delete("from Simple"),
2126
+
"delete by query");
2127
+
2128
+
s.Flush();
2129
+
s.Close();
2130
+
2131
+
s=sessions.OpenSession();
2132
+
enumer=s.Enumerable("from Simple");
2133
+
Assert.IsFalse(enumer.GetEnumerator().MoveNext(),"no items in enumerator");
0 commit comments