Groups | Blog | Home
all groups > dotnet framework > december 2006 >

dotnet framework : generate TypedDataSet with custom DataTable via designer


orenl
12/24/2006 6:07:45 AM
Hi,
Im using the VisualStudio 2005 designer to create typedDataSet (drag &
drop from the service explorer).
All the DataTables in the generated code inherit from
System.Data.DataTable, I would like the dataTables to inherit from
MyDataTable (a custom DataTable) instead.
How can I do that without manually editing the generated code?
RobinS
12/24/2006 10:58:19 AM
I don't think you can. You might be able to cast it to your
datatable when you instantiate it, though.

Also, you should *not* manually edit the generated code; it will be
recreated when/if you re-create the dataset, and wipe out any
changes you have made to it.

Robin S.
-----------------------------
[quoted text, click to view]

orenl
12/25/2006 2:55:08 AM
I know I shouldn't manually edit generated code thats why Im looking
for automatically inherit from MyDataSet.

there must be a way to changing cause I want to optionally implement
specified methods (and do not want the implementation to be mandatory
by using interfaces)
RobinS
12/26/2006 2:27:23 PM

The only thing I can think of is that you can access a strongly
typed dataset as an untyped one. So you could convert the
strongly-typed datatable to your derived datatable in order to
use whatever methods you want to use. You can then convert it
back to the strongly-typed dataset *IF* you haven't changed
its structure.

You can NOT convert any old untyped dataset to a strongly typed one
-- you can only convert one that was originally instantiated as the
strongly typed dataset.

'This is VB2005.
Dim dsStronglyTyped As New NorthwindDataSet()
Dim dsUntyped As DataSet
dsUnTyped = CType(dsStronglyTyped, DataSet)
'do some stuff to the data in the dataset, then convert it back
dsStronglyTyped2 = CType(dsUntyped, NorthwindDataSet)

Of course, you lose the features of the strongly typed dataset
when dealing with the untyped one.

Good luck.
Robin S.
----------------------------------------

[quoted text, click to view]

AddThis Social Bookmark Button