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 815395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:40:35+00:00 2026-05-15T01:40:35+00:00

I’m using EntityFrameowrk 4 and WinForms. I have a DataGridView which shows 5 to

  • 0

I’m using EntityFrameowrk 4 and WinForms.
I have a DataGridView which shows 5 to 12 thousands of records. The records are from different levels of hierarchy. There are records of classes
A, B, C, D, where A contains a collection of B, B contains a collection of C, etc. The most numerous class is D. In the DataGridView this hierarchy is flattened and each record is shown in the row with some color/font formatting. To do this type of rendering I wrote the following code:

foreach (a in A)
{
   var displayObjectA = new DisplayObject()
   {
      Name = a.Name,
      Code = "Section", 
      Object = a  
   }
   data.Add(displayObjectA);

   var B = a.B;

   foreach (b in B)
   {
      var displayObjectB = new DisplayObject()
      {
         Name = b.Name,
         Code = "Subsection", 
         Object = b  
      }
      data.Add(displayObjectB);

      var C = b.C;

      foreach (c in C)
      {
         var displayObjectC = new DisplayObject()
         {
            Name = c.Name,
            Code = "Group", 
            Object = c 
         }
         data.Add(displayObjectC);

         var D = c.D; 
         foreach (d in D)
         {
            var displayObjectD = new DisplayObject()
            {
               Name = d.Name,
               Code = d.Code, 
               Object = d 
            }
            data.Add(displayObjectD);
         }
      }
   }
}

after that the data is dispayed in the DataGridView.
The problem is that this rendering is taking too long. And the most time consuming part seems to be the line

foreach (d in D)

in particular the call to a function

System.Data.Objects.DataClasses.EntityCollection<T>.GetEnumerator(). 

When I looked at this function in Reflector it shows that it’s body is empty.

My questions are:

  1. Is there a better way to do this type of rendering?
  2. How do I increase the performance?
  3. Why is the GetEnumerator() empty? Is it constructed at run-time?
  • 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-05-15T01:40:36+00:00Added an answer on May 15, 2026 at 1:40 am
    1. Use paging as Darin suggested.
    2. Make sure you are loading all the inner collections using .Include() and don’t use lazy loading. Otherwise every access to the child collection of an entity will do an etxra request to the DB. And again, use paging.
    3. You’re probably using .NET 4 and looking at the Program Files\Reference Assemblies folder. These are just empty assemblies only containing metadata. The real ones are in Windows\Microsoft.NET. Or upgrade to Reflector 6.1 which is able to handle the mapping between the two.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.