Page 1 of 1

Does dotConnect support multiple DataReaders? (MARs)

Posted: Fri 05 Nov 2010 21:46
by gr33d
I found this post, http://www.devart.com/forums/viewtopic. ... esult+sets, but I'm not sure if it applies to my problem.

In the above post, the entity references look to be in class code. My reference is inline inside a user control, and I receive an error about a DataReader already being open: There is already an open DataReader associated with this Connection which must be closed first.

My user control code. profile.Addresses is valid

Code: Select all

Your search returned  result(s)

   Name: Address:" + profile.Addresses.First() %>
Is this supported? I'm coding in Entity Framework using dotConnect Beta 6.0.10 with Entity Developer Beta 3.0.10.[/quote]

Posted: Tue 09 Nov 2010 13:30
by Shalex
The thread you are referencing to in your post describes our LINQ to MySQL implementation that can use several connections and, thus, open several readers (one reader per one connection). You are using Entity Framework, ObjectContext of which works with one connection. MySQL Server does not support Multiple Active Result Sets, so we recommend you to exclude usage of lazy loading from your code.

Please use

Code: Select all

            TestEntities Model = new TestEntities();
            foreach (var profile in Model.results.Include("Addresses")) {
                Console.WriteLine(profile.FirstName);
                Console.WriteLine(profile.Addresses.FirstOrDefault());
            }
instead of

Code: Select all

            TestEntities Model = new TestEntities();
            foreach (var profile in Model.results) {
                Console.WriteLine(profile.FirstName);
                Console.WriteLine(profile.Addresses.FirstOrDefault());
            }