BusinessBase Child could not be a source for BindingSource in windows form...

BusinessBase Child could not be a source for BindingSource in windows form...

Old forum URL: forums.lhotka.net/forums/t/7792.aspx


saeedsamie posted on Thursday, October 15, 2009

Hi

When a root object has a BusinessBase child object and a few BusinessListBase child objects the BusinessBase child object would'nt appear as a BindingSource like BusinessListBase child objects to be controled by the same root BindingSource object in windows form.

Does anybody know why it is like that? and, is there any solution for it?

JonnyBee replied on Thursday, October 15, 2009

Hi,

Windows BindingSurce only understands 1:N relationships, not 1:1.

If you follow Rockys recommendations for UseCase you should not need a 1:1 relationship - your root object should contain all these properties. You seem to be using a Domain driven model and this just doesn't go that well with Windows Forms databinding.

Alternatively - you must consider each object in a 1:1 relationship a "separate" root objects that requires their own explicit BindingSource.

saeedsamie replied on Friday, October 16, 2009

Hi,

Ok, I know it is unwise to have two objects when you can have one. But actually my problem is that I have a xml data in Sql database which I should use its data along with other properties of the object. Yes I can read this xml data directly into the corresponding properties I create for them in the object. But since I need this  xml data in deferent objects I decided to have a BusinessBase object for it to be used as child objects of deferent kind of objects. So this child send back its data as xml to its parent for saving into database. I know I am breaking the encapsulation rule for data persistance but I found it less work than I write a lot of repeated properties in defferent objects. I appritiate your idea.

Thanks,

Copyright (c) Marimer LLC