Andria Jensen
|
|
Group: Forum Members
Posts: 336,
Visits: 497
|
I have a BO on my form which uses a few other BOs to get property and the like. I would like to have properties on my primary BO which point to properties on the secondary BO. For example if I have a secondary BO called Clients which is linked by the ClientKey on the primary/seconday BO, and want to get the Client Description I would have a property like this: Public ReadOnly Property ClientDescription as String Get Return Clients.Description End Get End Property The question I have is how I keep Clients looking at the right record when I am navigating around in the primary BO. I fill the Clients BO with all clients in the Fill of the primary BO and I have some code in the Navigated and CurrentDataTableRefilled event handlers to navigate Clients to the correct primary key when the primary BO record changes. My problem is that when I get into the Navigated event my Clients.Count is 0. When it starts the Fill method the Client count is a few hundred, but it clears it out somewhere along the way. Any idea what I am doing wrong here, or if there is a better way of doing what I'm trying to accomplish? I can't really use the parent/child relationship here because it doesn't make sense in other areas of the database/code.
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Have you checked the count in the navigating event? Maybe put a break there and then step through to see when it goes to zero.
|
|
|
Andria Jensen
|
|
Group: Forum Members
Posts: 336,
Visits: 497
|
Actually, by the time it gets into the Navigating event Clients.Count is already zero. It is 353 in the PrimaryBO_CurrentDataTableRefilled handler, but then when it goes to the PrimaryBO_Navigating event where I would expect to change where Clients is pointing, the count is back to zero. I'm just not sure what's happening here...any other ideas anyone?
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
You might check the CurrentDataTable.Rows.Count and Filter properties to make sure that the records are not being filtered out. Since the business object navigates off of the CurrentView, it might be that the records are still there, but just not visible for some reason.
|
|
|
Andria Jensen
|
|
Group: Forum Members
Posts: 336,
Visits: 497
|
The CurrentDataTable.Rows.Count corresponds to Clients.Count....both are correct when in the PrimaryBO_CurrentDataTableRefilled handler, but when it gets to the PrimaryBO_Navigating event handler, the counts are zero and there is not a Filter set, it is "". I looked at the BusinessLayer code here and there wasn't much going on between these events that I could see. I also don't handle any events for Clients and it is a private object so it's not messed with anywhere else either. I will continue looking, but I can't see anywhere I am filtering the rows or refilling the table.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Hrm... you could try putting a handler on the CurrentDataTableRefilled event of the child business object and put a break point in it. Then look at the CallStack window and see what called the refill further up the line.
|
|
|
Andria Jensen
|
|
Group: Forum Members
Posts: 336,
Visits: 497
|
I actually have breaks in Clients_CurrentDataTableRefilled, Navigating, and Navigated. None of these are hit in between the primary BO events I talked about. They are hit before that and the values are correct at that point, but between the CurrentDataTableRefilled and Navigating of the primary BO the row count value changes.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
If you have the SF source code built in debug, you can put a breakpoint in the BusinessLayer.vb file somewhere around 2109 or 2110 which should be the ChangeCurrentDataTable() method. It should get hit when the table is refilled or cleared (when a Clear() is called). You might give that a try...
|
|
|
Andria Jensen
|
|
Group: Forum Members
Posts: 336,
Visits: 497
|
Ok, one thing I think I did leave out was that the primary BO is used in a BusinessBindingSource to display in a DevExpress TreeList. I mention that now because the Clients.Count seems to change somewhere in the following code. Is there anything in here that could be causing something to fire off somewhere else I'm not aware of?? Private Sub BusinessObject_CurrentDataTableRefilled() '-- Remove the handler on the old current view RemoveHandler _BusinessObject_CurrentView.ListChanged, AddressOf BusinessObject_CurrentView_ListChanged '-- Save a reference to the new view Me._BusinessObject_CurrentView = Me._BusinessObject.CurrentView '-- Add the handler to the new view AddHandler Me._BusinessObject_CurrentView.ListChanged, AddressOf BusinessObject_CurrentView_ListChanged '-- Raise the list changed event Me.OnListChanged(New ListChangedEventArgs(ListChangedType.Reset, -1)) End Sub
|
|
|
Andria Jensen
|
|
Group: Forum Members
Posts: 336,
Visits: 497
|
Ok, I have a little more information I'm not sure what to make out of. When it raises the ListChanged event in the BusinessBindingSource code like this: Protected Overridable Sub OnListChanged(ByVal e As ListChangedEventArgs) RaiseEvent ListChanged(Me, e) End SubI set a break at the raiseevent and step, but before it comes back from the event it hits the break in the Primary BO's Navigating event and my Clients.Count is back to zero. Before the ListChanged event is raised the Clients.Count is correct. Is this a DevExpress thing or is this an issue with how the BindingSource is interacting with it or do you have any idea what's going on here?
|
|
|