I have a problem retrieving items count in a silverlight application, to populate the combo box with items from sql i use the following code:
objctx = New BanksDomain
Dim itemType = NameComboBox.SelectedItem.[GetType]()
Dim pi = itemType.GetProperty(NameComboBox.DisplayMemberPath)
Dim cbi = pi.GetValue(NameComboBox.SelectedItem, Nothing).ToString()
Dim BankName As String = cbi
Dim query As EntityQuery(Of Branches) = objctx.GetBranchesByBankQuery(BankName)
query.IncludeTotalCount = True
Dim loadOp As LoadOperation(Of Branches) = Me.objctx.Load(query)
Branch_NameComboBox.ItemsSource = loadOp.Entities
i have tried getting the count from the combobox items count with no avail, i have tried to load it by the textbox.text = loadop.entities.count but it shows "0"
i have no idea whats wrong and i seem not be able to do it, although it should be really simple, may somebody help me out
Do not forget than call to RIA services are Asynchronous. Thus the load function return an async result.
Dim loadOp As LoadOperation(Of Branches) = Me.objctx.Load(query)
Branch_NameComboBox.ItemsSource = loadOp.Entities
Then, if you check your itemsSource.count() just after the load call, it will still be 0. But if you wait for the asynchronous result (possibly process it in the callback of the load function), you will see the real results of the request, and it should not be 0 if your request is correct.