Same BO appear multiple instance in ChildBusinessObject collection


Author
Message
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I have a form contains two business objects. I used ASPxGridView to bind to WebBBS which attach CHildBO. In Page_Load, I have code to set ChildBO.ParentBusinessObject = ParentBO if !IsPostback.



I am facing problem that, whenever I add new record to ASPxGridView, WebBBS.CreateShareAndAddBusinessObject() would be fired. In this method, it will clone the ChildBO; assign ChildBO.ParentBusinessObject to ClonedBO.ParentBusinessObject.



Whenever this happens, program try to access the ParentBO instance and add ClonedBO to its ChildBusinessObject collection. As all BOs are stored in Session, it cause existing ParentBO.ChildBusinessObjects retain and keep been added new ClonedBO.



It caused some error for that if I loop thru ParentBO.ChildBusienssObjects to do something.



Please advice.
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

After further debugging, I found that, SF create multiple instance of BO in order to support "Enumerator". It is understandable. However, it caused multiple instance of same BO class in ChildBusinessObjects.



Currently, I try to loop thru ChildBusinessObjects and check for its TableName in order to get "distinct" list. However, it is not bullet proof as if that is a need to have same BOs (diff instance) in same web page would cause another issue as well.



Please advice.



Thank you
Govinda Berrio
Govinda Berrio
StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)
Group: StrataFrame Users
Posts: 94, Visits: 481
I've found the a very similar issue. If I set the ParentBusinessObject on a BO in the Page_Load (!IsPostBack) after a postback, the ParentBusinessObject child collection has new duplicated entries of the same child BO. I've been meaning to create a sample project to demonstrate this, but I haven't gotten around to it yet.
Govinda Berrio
Govinda Berrio
StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)StrataFrame User (240 reputation)
Group: StrataFrame Users
Posts: 94, Visits: 481
I should also note that both the Parent and Child BOs are declared in the BasePage
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I could see how this might happen, but I have not been able to reproduce.  If possible, could you please post a quick sample showing how to reproduce this so that we can see this in action.  Once we can reproduce this things will move much faster.  Thanks!
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

Please download sample project from http://www.visualsolutions.com.my/blog/chankk/WebApplication2.zip.

Set breakpoint at line Me._BusinessObjectList.Add(index, loReturn) of BusinessBindingSource.CreateShareAndAddBusinessObject() method.



Run the project, click new button from ASPxGridView, key in value and click "Update" link.



Use watch window to check the value of loReturn.ParentBusinessObject.ChildBusinessObjects.Count when debugger hit that line.



You would find that, it keep increasing everytime new record added.



Please advice, urgent!



Thank you
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (652 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Chan,

We downloaded your sample and ran through it, but I'm not seeing the point of failure. Could you provide some additional information?

After wiring up your sample to work in our environment, I run your app and end up with a grid with a single record in it (the bottomost record from the database). After clicking new, I enter valid values into all fields and click update. The original grid is then populated with a single record containing my specified values. These values are not being saved back to the server (I assume a save is not being called here?). Regardless, the ChildBO count label stays at 1 which, as I understand it, is your point of failure.

Where are you placing your breakpoint? Do you intend for the data from a new record to be saved on the SQL server? Is your childBO issue being reflected by your label on your end?

Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

Sorry for misleading, the label would not be refreshed anyway.

As mentioned in previuos post, I placed breakpoint at line



'-- Set the parent business object of the instance object

loReturn.ParentBusinessObject = _BusinessObject.ParentBusinessObject



'-- Add the object to the list

Me._BusinessObjectList.Add(index, loReturn)





of BusinessBindingSource.CreateShareAndAddBusinessObject().



The data would not be saved to database as we need to call BO.Save manually.



I also uploaded video to show the behavour. http://www.visualsolutions.com.my/blog/chankk/bbs.zip



Please advice. urgent!

Thank you
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

May I know if SF team is checking on it?

I need it to be solve urgently.



Please advice.

Thank you
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

May I know any status updated? Are you overlook this issue?

I need to fix it ASAP as it seem to cause memory leak.



Please help!!!



Thank you
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search