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

  • Home
  • SEARCH
  • 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 6648469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:39:31+00:00 2026-05-26T00:39:31+00:00

I have a table with 6400 rows. This is a parent-children table, it has

  • 0

I have a table with 6400 rows. This is a parent-children table, it has a foreign key to it self (a self-association reference in EF).

For this project, all tree must be loaded (load data when node is expanded is not a solution for me)

I have tried to load all nodes/tree at a time, but it exceed maximun items: “The InnerException message was ‘Maximum number of items that can be serialized or deserialized in an object graph is ‘65536’.”

Then I have tried to load data recursively, but maximun simultanius connections are maded (http://msdn.microsoft.com/en-us/library/cc304129%28VS.85%29.aspx). This is because loadoperation is asyncronous and recursion runs un parallel way.

Finaly I have write this code to load the data, it works (slowly) but I think that this is dirty solution:

Private Sub loadOperation_Completed(ByVal sender As Object, ByVal e As EventArgs)

        Dim localloadOperation As LoadOperation(Of dimActivitats) = DirectCast(sender, LoadOperation(Of dimActivitats))

        If Not localloadOperation.HasError Then
            Dim llista = localloadOperation.Entities.ToList
            If llista.Any AndAlso llista.First.idSubrogatPare Is Nothing Then
                activitatsTree = llista
                TreeViewTaula.DataContext = activitatsTree
            End If

            For Each i In llista
                elementsWaitingForExpand.Push(i)
            Next
        End If

        Dim take10 = 10
        Dim IdsParentListOfElementsToProcessNow As New List(Of Integer)
        While elementsWaitingForExpand.Count > 0 And take10 > 0
            take10 -= 1
            IdsParentListOfElementsToProcessNow.Add(elementsWaitingForExpand.Pop.idSubrogat)
        End While
        Dim q2 = CActx.GetDimActivitatsListChildQuery(IdsParentListOfElementsToProcessNow)
        loadOperation = CActx.Load(Of dimActivitats)(q2)
        AddHandler loadOperation.Completed, AddressOf loadOperation_Completed

        ProgressBarTaula.Value = CActx.dimActivitats.Count

    End Sub

I’m looking for some thing more elegant (semaphor? monitor? queue? ).


Here you can see a previeus solution that raise error due simultanius connections:

Private Sub loadOperation_Completed(ByVal sender As Object, ByVal e As EventArgs)
    Try
        Dim localloadOperation As LoadOperation(Of dimActivitats) = DirectCast(sender, LoadOperation(Of dimActivitats))

        If Not localloadOperation.HasError Then
            Dim llista = localloadOperation.Entities.ToList
            If llista.Any AndAlso llista.First.idSubrogatPare Is Nothing Then
                activitatsTree = llista
                TreeViewTaula.DataContext = activitatsTree

            End If

            TreeViewTaula.Dispatcher.BeginInvoke(New loadLlistaDelegate(AddressOf loadLlista), llista)
        End If
    Catch ex As Exception
    End Try
End Sub

Private Delegate Sub loadLlistaDelegate(ByVal llista As List(Of dimActivitats))
Private Sub loadLlista(ByVal llista As List(Of dimActivitats))
    For Each item In llista
        For Each fill In item.dimActivitatsChildren
            Dim q2 = CActx.GetDimActivitatsChildQuery(fill.idSubrogat)
            Dim newloadOperation = CActx.Load(Of dimActivitats)(q2)
            AddHandler newloadOperation.Completed, AddressOf loadOperation_Completed
        Next
    Next
End Sub

Do you have any idea to rewrite this code in more elegant way?

  • 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-26T00:39:31+00:00Added an answer on May 26, 2026 at 12:39 am

    Do you have the maxItemsInObjectGraph setting in your service behavior in the web.config set to the maximum ? e.g

      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <!--The service behavior for the RIA Service-->
            <behavior name="RIAServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <dataContractSerializer **maxItemsInObjectGraph="2147483647"** />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table inside a div tab. The table has 40 rows in it
I have a table with more than a millon rows. This table is used
I have table rows of data in html being filled from a CGI application.
Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
I have a table which is full of arbitrarily formatted phone numbers, like this
I have table that has a column of type DateTime, I would like to
I have table like this create table tbl_1( year int, month int, day int
I have table with 50 entries (users with such details like Name Surname Location
While trying to use LINQ to SQL I encountered several problems. I have table
I have a table in a SQL Server 2005 database with a trigger that

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.