generate TypedDataSet with custom DataTable via designer

O

orenl

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?
 
R

RobinS

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.
 
O

orenl

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)
 
R

RobinS

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.
 
O

orenl

but my problem is that I don't want to loose the benefits of strongly
typed DataSet.

there must be a way to extend the VisualStudio2005 typedDataSet
designer.
the current designer is MSDataSetGenerator and I don't know how to see
its code.
 
R

RobinS

You could try generating your own typedDataSet.

You create your dataset in code using FillSchema,
then do a dataset.WriteXmlSchema to create an XSD file.
Then you use the XML Schema Definition Tool to generate
a class file based on the XML schema. Then you can
add the class to your project.

I can post the code if you want me to, but I'm not sure it
is going to get you anywhere. It's pretty much the same as
doing it in Visual Studio.

Other than that, I don't know of a way to do what you're
trying to do. You could try posting to
microsoft.public.dotnet.framework.adonet
and see if Bill Vaughn can help you.

Robin S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top