Why would you not read the objects in a simple table join from the
server? Surely that is what database servers are designed for. Just
order the results correctly and you do not need to open 2 readers at all
and the code is straightforward.

Just wondered! :-)

Cheers,
Iain

> -----Original Message-----
> From: Burkhard Perkens-Golomb [mailto:[EMAIL PROTECTED] 
> Sent: 25 June 2003 10:25
> To: [EMAIL PROTECTED]
> Subject: [ADVANCED-DOTNET] ADO.NET vs. JDBC: Several open 
> ResultSets/DataReader simultansously with same connection
> 
> 
> I'm porting a Java application to .NET. And it seems that ADO.NET is
> not as good as JDBC in some ways.
> 
> In Java/JDBC you can have several open ResultSets with the same
> connection. In ADO.NET you have to close an open DataReader before you
> can open the next DataReader with the same connection.
> 
> What I want to do:
> 
> - I want to read objects with an 1:m relation (I call them "1-objects"
>   and "m-objects").
> - I want to read the 1-objects one by one and read for every
>   1-objects the associated m-objects.
> - I don't want to read *all* 1-objects first before I
>   start to read associated "m-objects".
> - I want to read all objects (1 and m) in the same transaction.
> 
> Here's the C# pseudo code what I want to do:
> 
> ,----
> | IDbConnection connection;
> | IDbComman command;
> | IDataReader reader, reader2;
> |
> | // open a connection
> | connection = new MySqlConnection();
> | connection.Open();
> |
> | // start reading "1-objects"
> | command = connection.CreateCommand();
> | command.CommandText = "SELECT ...";
> | reader = command.ExecuteReader();
> |
> | while (reader.Read())
> | {
> |   // read "m-objects"
> |
> |   // Open a second IDataReader before closing the first:
> |   // ok in Java, not ok in .NET!!!
> |
> |   command = connection.CreateCommand();
> |   command.CommandText = "SELECT ...";
> |   reader2 = command.ExecuteReader();
> |   while (reader2.Read()) { ... }
> |
> |   reader2.Close();
> | }
> |
> | reader.Close();
> `----
> 
> I could use a second connection for reading m-objects but then I'm not
> in the same transaction as with the first connection.
> 
> How can I do in ADO.NET what I can do with JDBC? Any solution to
> circumvent this limitation in ADO.NET?
> 
> Thanks,
> 
>         Burkhard
> 

Reply via email to