Hello,

I was curious as to why one would want to use a strongly-typed
collection (generated from a tool of some such) versus using a
strongly-typed dataset (generated from an xsd).

Here's why I'm asking: I figured a collection would be easier since I
had a bunch of objects and I wanted to be able to add/remove them, etc.
But then I also wanted to databind them to a listbox control.  Here's
the catch: while the databinding works (since the collection implements
IList), it's not really useful.  If you add/remove/change elements in
the databound collection, the listbox is not updated.  It's not very
well documented, but if you want auto-updating to work, then your
collection must implemente IBindingList[1].  Among classes that do
implement that interface are DataView's, DataTable's, and DataSet's.

So that begs the question.  Why not just always use a strongly-typed
DataSet, since that way databinding will always work as expected.

Is there some reason not to use one over the other?  What about
performance?  At what point is one worth the trade-off of the other?

It seems like you can create a simple XSD using the designer that has
the same functionality as a custom collection.  Just put a single
Element there and in it, put your columns and types.  If you want, set a
primary key.  That very nicely corresponds to a collection of a given
type...

Any thoughts?


[1]
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemComponentModelIBinding
ListClassTopic.htm


--Oren

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to