Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8112241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:25:14+00:00 2026-06-06T02:25:14+00:00

Possible Duplicate: Entity Framework: There is already an open DataReader associated with this Command

  • 0

Possible Duplicate:
Entity Framework: There is already an open DataReader associated with this Command

I have these classes:

    public class VwSelectBrochures
{
    public List<SelectBrochure> SelectBrochures { get; set; }
}

   public class SelectBrochure
{
    public int BrochureId { get; set; }
    public string UrlImage { get; set; }
    public string Description { get; set; }
    public string Cat1Description { get; set; }
    public string Cat2Description { get; set; }
    public string Cat3Description { get; set; }
    public List<LangSelection> Languages { get; set; }
}

public class LangSelection
{
    public int Id { get; set; }
    public string Description { get; set; }
    public bool Vink { get; set; }
}

and this line of code:

var dbmodel2 =
from x in
    brochures.AsEnumerable().Select(
        x => new SelectBrochure {BrochureId = x.Id, Description = x.Description, UrlImage = x.UrlImage,
        Languages = new List<LangSelection>(from y in x.BrochureLanguages select new LangSelection(){Description = y.Language.Description, Id = y.Language.Id})})
select x;

Brochures and BrochureLanguages are my db-models.

I know I get the error, because I can’t do the “from y in x.BrochureLanguages”, but I don’t see how I can fix this.

What I really want is to get all the brochures into the VwSelectBrochures class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:25:17+00:00Added an answer on June 6, 2026 at 2:25 am

    The easiest way is to bring the whole brochures into the memory (using ToList()) first:

    var dbmodel2 =
    from x in
        brochures.ToList().Select(
            x => new SelectBrochure {BrochureId = x.Id, Description = x.Description, UrlImage = x.UrlImage,
            Languages = new List<LangSelection>(from y in x.BrochureLanguages select new LangSelection(){Description = y.Language.Description, Id = y.Language.Id})})
    select x;
    

    This way when running from y in ... there is no other DataReader open. I think there is another option using a join.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Conditional Linq Queries Using Entity Framework 4.0 I have a search condition
Possible Duplicate: Problem with simpleXML and entity not being defined I have this tag
Possible Duplicate: Entity Framework with NOLOCK I'm using EF4 and .Net 4 to load
I have this really strange problem where my entity framework query isn't enumerating correctly.
Possible Duplicate: getting identity row value using ADO.NET Entity This is my example code:
Possible Duplicate: What is the best way to compare two entity framework entities? I
Possible Duplicate: Entity Framework Code First: decimal precision I'm using Linq-to-Entities with the EntityFramework
Possible Duplicate: Entity Framework Include() strongly typed Ok, I've got an entity framework query
Possible Duplicate: Hibernate: different object with the same identifier value was already associated with
Possible Duplicate: Entity framework 4 not closing connection in sql server 2005 profiler Well,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.