Note that there are some explanatory texts on larger screens.

plurals
  1. POLoad a big silverlight treeview (question for silverlight masters!)
    primarykey
    data
    text
    <p>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).</p> <p>For this project, all tree must be loaded (load data when node is expanded is not a solution for me)</p> <p>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'."</p> <p>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.</p> <p>Finaly I have write this code to load the data, it works (slowly) but I think that this is dirty solution: </p> <pre><code>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 &gt; 0 And take10 &gt; 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 </code></pre> <p>I'm looking for some thing more elegant (semaphor? monitor? queue? ). </p> <hr> <p>Here you can see a previeus solution that raise error due simultanius connections:</p> <pre><code>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 </code></pre> <hr> <p>Do you have any idea to rewrite this code in more elegant way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload