0
using (var context = new PostBoard()) {

                var projectresult = context.projects.Select(pro => new  {
                    pro.id,
                    pro.participant_name,
                    pro.moderator_name,
                    pro.start_date,
                    pro.end_date,
                    pro.account_id,
                    discussion_sections = pro.discussion_sections.Select(ds => new {
                        ds.id,
                        ds.title,
                        ds.project_id
                    }).Where(ds => ds.project_id == pro.id)
                }).Where(pro => pro.id == id);

                var test = projectresult;
}

When I try and debug and view projectresult results when its being assigned to test I am getting an error stating that there is already an open data reader.

allencoded
  • 7,015
  • 17
  • 72
  • 126
  • You can't have to readers at the same time on a same connection. You should rather link those in the data definition and Include() the results. It would be a lot more performant also – Sami Kuhmonen Jan 12 '16 at 06:47
  • 4
    Yes, you can have more than one reader open at one single time, you have to add `MultipleActiveResultSets=true` to your connection string. – jvanrhyn Jan 12 '16 at 07:07
  • Possible duplicate of [There is already an open DataReader associated with this Command which must be closed first](https://stackoverflow.com/questions/6062192/there-is-already-an-open-datareader-associated-with-this-command-which-must-be-c) – dovid Jun 28 '17 at 22:22

0 Answers0