Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4733/Impl
Modified Files:
EnumerableImpl.cs
Log Message:
Cleaned up the implementation details in the class.
Index: EnumerableImpl.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/EnumerableImpl.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** EnumerableImpl.cs 29 Mar 2004 04:03:17 -0000 1.3
--- EnumerableImpl.cs 27 Aug 2004 04:14:19 -0000 1.4
***************
*** 13,17 ****
/// This is the IteratorImpl in H2.0.3
/// </remarks>
- //TODO: revisit this class and make sure the port is what is intended
internal class EnumerableImpl : IEnumerable, IEnumerator
{
--- 13,16 ----
***************
*** 22,36 ****
private IType[] types;
private bool single;
- private object[] nextResults;
private object[] currentResults;
private bool hasNext;
private string[][] names;
! private IDbCommand ps;
! //TODO: H2.0.3 change ctor to include ps
! public EnumerableImpl(IDataReader rs, ISessionImplementor sess, IType[] types, string[][] columnNames)
{
this.rs = rs;
! //this.ps = ps;
this.sess = sess;
this.types = types;
--- 21,33 ----
private IType[] types;
private bool single;
private object[] currentResults;
private bool hasNext;
private string[][] names;
! private IDbCommand cmd;
! public EnumerableImpl(IDataReader rs, IDbCommand cmd, ISessionImplementor sess, IType[] types, string[][] columnNames)
{
this.rs = rs;
! this.cmd = cmd;
this.sess = sess;
this.types = types;
***************
*** 38,63 ****
single = types.Length==1;
-
- //TODO: find out if we do need to move to the NextResult right away.
- //PostNext(rs.NextResult());
}
! private void PostNext(bool hasNext)
{
this.hasNext = hasNext;
if (!hasNext)
{
log.Debug("exhausted results");
! nextResults = null;
rs.Close();
//TODO: H2.0.3 code to synch here to close the QueryStatement
}
else
{
log.Debug("retreiving next results");
! nextResults = new object[types.Length];
for (int i=0; i<types.Length; i++)
{
! nextResults[i] = types[i].NullSafeGet(rs, names[i], sess, null);
}
}
--- 35,60 ----
single = types.Length==1;
}
! private void PostMoveNext(bool hasNext)
{
this.hasNext = hasNext;
+
+ // there are no more records in the DataReader so clean up
if (!hasNext)
{
log.Debug("exhausted results");
! currentResults = null;
rs.Close();
//TODO: H2.0.3 code to synch here to close the QueryStatement
+ //sess.Batcher.CloseQueryStatement( cmd, rs );
}
else
{
log.Debug("retreiving next results");
! currentResults = new object[types.Length];
for (int i=0; i<types.Length; i++)
{
! currentResults[i] = types[i].NullSafeGet(rs, names[i], sess, null);
}
}
***************
*** 77,85 ****
if (single)
{
! return nextResults[0];
}
else
{
! return nextResults;
}
}
--- 74,82 ----
if (single)
{
! return currentResults[0];
}
else
{
! return currentResults;
}
}
***************
*** 88,97 ****
public bool MoveNext()
{
! PostNext(rs.Read());
return hasNext;
}
! public void Reset() {
//can't reset the reader...we are SOL
}
--- 85,95 ----
public bool MoveNext()
{
! PostMoveNext( rs.Read() );
return hasNext;
}
! public void Reset()
! {
//can't reset the reader...we are SOL
}
|