Does dotConnect support multiple DataReaders? (MARs)

Does dotConnect support multiple DataReaders? (MARs)

Postby gr33d » Fri 05 Nov 2010 21:46

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 <%: Model.numResults %> result(s)


<% foreach (var profile in Model.results)
   { %>
   

Name: <%= profile.FirstName + " " + profile.LastName + " 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]
gr33d
 
Posts: 11
Joined: Tue 05 Oct 2010 21:46

Postby Shalex » Tue 09 Nov 2010 13:30

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());
            }
Shalex
Devart Team
 
Posts: 7774
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL