|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
generate TypedDataSet with custom DataTable via designerHi,
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? 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. ----------------------------- Show quote "orenl" <oren***@yahoo.com> wrote in message news:1166969265.520177.256980@a3g2000cwd.googlegroups.com... > 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? > 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) 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. ---------------------------------------- Show quote "orenl" <oren***@yahoo.com> wrote in message news:1167044108.593552.82580@h40g2000cwb.googlegroups.com... >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) > 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. 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. -------------------------------------- Show quote "orenl" <oren***@yahoo.com> wrote in message news:1167307301.407946.322360@42g2000cwt.googlegroups.com... > 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. > |
|||||||||||||||||||||||