471,319 Members | 1,296 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Customizing MSDataSetGenerator output in VS2005

Hi,
I am using a strongly typed dataset in .Net 2.0, and would like all
tables to inherit from a cusomt datatable class instead of DataTable.
The reason for this is that I want some common code excuted on the row
events, and this I want to implement this once in a Table base class.
ie. instead of having this code generated:
public partial class ActivitiesDataTable : System.Data.DataTable,
System.Collections.IEnumerable {
I would like the tables to inherit from MyDataSet like this:
public partial class ActivitiesDataTable : CustomDataTable,
System.Collections.IEnumerable {
1) How can this be achieved. Is it possible to create a custom
generator that inherits from the MSDataSetGenerator, and override the
parts where the nested table classes are generated ?
2) In what assembly can I find the MSDataSetGenerator to do this?
3) Now that .Net 2.0 MSDataSetGenerator uses partial classes for the
DataSet, table and row classes, I could add my code without having it
overridden, but then I would have to edit each and every table and row
class in the generated dataset.
4) What is the best solution to customize the generated typed datasets
?
Regards
Stig Nielsson

Dec 6 '05 #1
3 16614
Stig,

This article should help you. It tells you how to generate code with
custom generators:

http://www.drewnoakes.com/snippets/W...rVisualStudio/

You could easily call into the MSDataSetGenerator tool, parse the code,
and replace where needed.

You can also try this:

http://www.raboof.com/Projects/VsCod...ratorShim.aspx

Either way, you should call the old code generator, get the code, and
then pass it to CodeDom. Then, you can change your code, output it, and
then send it back.

You are going to take a hit doing this though, since the code will be
constructed, torn apart, then reconstructed again.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Stig Nielsson" <st****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
I am using a strongly typed dataset in .Net 2.0, and would like all
tables to inherit from a cusomt datatable class instead of DataTable.
The reason for this is that I want some common code excuted on the row
events, and this I want to implement this once in a Table base class.
ie. instead of having this code generated:
public partial class ActivitiesDataTable : System.Data.DataTable,
System.Collections.IEnumerable {
I would like the tables to inherit from MyDataSet like this:
public partial class ActivitiesDataTable : CustomDataTable,
System.Collections.IEnumerable {
1) How can this be achieved. Is it possible to create a custom
generator that inherits from the MSDataSetGenerator, and override the
parts where the nested table classes are generated ?
2) In what assembly can I find the MSDataSetGenerator to do this?
3) Now that .Net 2.0 MSDataSetGenerator uses partial classes for the
DataSet, table and row classes, I could add my code without having it
overridden, but then I would have to edit each and every table and row
class in the generated dataset.
4) What is the best solution to customize the generated typed datasets
?
Regards
Stig Nielsson

Dec 6 '05 #2
thanks for the answer - it looks as a promising idea.

I succeeded in creating and registering a custom code generator, and it
works in VS2005. Now I would like this generator to invoke the
MSDataSetGenerator to get its generated code, but I dont know how to
achive this (as I don't have much COM experience).

Should I create a reference to a COM object in my project? I have tried
doing this, but cannot find any com object that is called
MSDataSetGenerator

So when you write

"Either way, you should call the old code generator, get the code, and
then pass it to CodeDom. Then, you can change your code, output it,
and
then send it back. "

how should I do this?

regards

Stig Nielsson

Dec 7 '05 #3
The Xsd.exe tool in the SDK generates the same dataset code as
MSDataset generator, so one solution to my questions above could be to
fork of a process in my generator to create a temporary dataset file,
which I then somehow load into a CodeDom which I then can modify and
write to a souce file.

I am pretty sure this would work, but it seems a bit clumsy. Does any
one have a better idea ?

regards

Stig Nielsson

Dec 8 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by kjcox | last post: by
3 posts views Thread by John | last post: by
1 post views Thread by Joe Reggae | last post: by
reply views Thread by John Olbert | last post: by
20 posts views Thread by Ilias Lazaridis | last post: by
11 posts views Thread by aaragon | last post: by
2 posts views Thread by thecoolone | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.