PC Review


Reply
Thread Tools Rate Thread

Customizing MSDataSetGenerator output in VS2005

 
 
Stig Nielsson
Guest
Posts: n/a
 
      6th Dec 2005
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

 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      6th Dec 2005
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]
- (E-Mail Removed)

"Stig Nielsson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Stig Nielsson
Guest
Posts: n/a
 
      7th Dec 2005
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

 
Reply With Quote
 
Stig Nielsson
Guest
Posts: n/a
 
      8th Dec 2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Customize MSDataSetGenerator in VS.NET 2005 Dirk Microsoft ADO .NET 0 7th Aug 2006 01:39 PM
MSDataSetGenerator Failed Joe Reggae Microsoft ASP .NET 1 23rd Feb 2006 05:38 PM
Customizing MSDataSetGenerator output in VS2005 Stig Microsoft ADO .NET 1 6th Dec 2005 02:12 PM
MSDataSetGenerator and strongly typed DataSets in VS.NET 2005 Beta =?Utf-8?B?Um9iZXJ0IFcuIExhcmdlbnQ=?= Microsoft ADO .NET 0 24th Jan 2005 09:15 PM
The custom tool 'MSDataSetGenerator' failed while processing the file... lover Microsoft ADO .NET 2 11th Feb 2004 05:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:59 AM.