Hello,
I do not want to bind my DataSets to my UI controls because my database
schema will change often. I want to have another layer of Business Object
between my UI and my database (datasets). As my db schema changes I can
localize all code changes to the mapping between the dataset and the
business objects.
I have already made my business objects data bindable by implementing the
IBindingList interface. This works well. My business objects now stay in
sync with the UI.
I now what to make my business objects bind to my datasets. How can I do
this? Is there an interface that I need to add to my business objects such
that they can except data sources, i.e. datasets?
Thanks for any help...
-dh
Roman Pokrovskij - 24 Jun 2004 17:06 GMT
Hello David,
> I have already made my business objects data bindable by
> implementing the IBindingList interface. This works well.
Is it really true ? The specialist who may do such things can't ask such
question... :-) May be you want to ask: "what I should do after I will
implement IBindingList" ?
> I now what to make my business objects bind to my datasets.
> How can I do this? Is there an interface that I need to add to
> my business objects such that they can except data
> sources, i.e. datasets?
You should implement in your business objects a set of XxxxChanged
events, then handle those events and change the underlying dataset.
Roman Pokrovskij - 27 Jun 2004 20:11 GMT
Hello David,
I can present one "low" that can be interesting for you:
It is impossible to build real world application using "two level data
binding (binding in sence of Windows.Forms Data Binding API)".
Why:
In the real world exists a combobox which values list depends on the other
field value. Therefore you should refresh this combox each time after this
our field was changed. If you are using "buisness logic layer", then you
should rebuild underlying business objects collection. An this is impossible
if you use binding on "SelectedItem" combobox property.
An example:
class Company
{
CompanyType companyType;
}
class CompanyType
{
string name;
public void ToString()
{
return name;
}
}
class CompanyTypes: DictionaryBase
{
//. CompanyTypes and ther ID
}
class form:Form
{
// ... somewhere in initialization:
this.compTypeComboBox.DataSource = new
ArrayList(ResourceManager.CompanyTypes.Values);
this.compTypeComboBox.DataBindings.Add( "SelectedItem",
company,"CompanyType");
}
Note:
You can't simply construct new CompanyTypes collection based on new query
( SELECT * FROM dbo.CompanyTypes WHERE ...) Of course because you should
maintain Company.CompanyType reference validity. Therefore you should
impplement your own SQL language on your buisness objects. What is not
organic venture for appliactive programming.
> I do not want to bind my DataSets to my UI controls because my database
> schema will change often. I want to have another layer of Business Object
[quoted text clipped - 13 lines]
>
> -dh
Dan - 01 Jul 2004 15:45 GMT
David,
I found this link on MSDN:
<a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/d
nadvnet/html/vbnet02252003.asp">http://msdn.microsoft.com/library/defaul
t.asp?url=/library/en-us/dnadvnet/html/vbnet02252003.asp</a>
Hope it helps.