Bug #39284 Table adapters define constructor not allowing me to
Submitted: 5 Sep 2008 21:35 Modified: 31 Aug 2011 20:16
Reporter: Chris Robison Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S4 (Feature request)
Version:5.2.3 OS:Windows (Vista Enterprise x86)
Assigned to: Julio Casal CPU Architecture:Any
Tags: data sets, table adapters

[5 Sep 2008 21:35] Chris Robison
Description:
When you use the DataSet designer in Visual Studio, you can double click on a TableAdapter and Visual Studio will generate some partial classes for that table adapter/data set. This is useful if you want some custom processing on instantiation of a table adapter or data set. 

The code generated using a DataSet against a Microsoft MSSQL server doesn't define a default constructor in the <DataSet>.Designer.cs file classes. The MySQL <DataSet>.Designer.cs classes do define the default constructor making it so if I want to have special processing done on instantiation, I have to do it in the <DataSet>.Designer.cs generated code. That's not guaranteed to be there the next time I change the data set in any way. Would it be possible to not define the default constructor and let that be something done in a partial class? 

How to repeat:
1. Create a dataset
2. Create a table adapter
3. Double click on the tiny icon next to table adapter name in the designer to have Visual Studio generate the new CS file (usually named <DataSetName>.cs)
4. Try to define the default constructor in one of the partial classes and compile. 
5. Should error saying it is already defined.

Suggested fix:
No fix that I've found.
[5 Sep 2008 21:38] Chris Robison
Default Constructor error

Attachment: DefaultConstructor.jpg (image/jpeg, text), 45.44 KiB.

[8 Sep 2008 8:23] Tonci Grgin
Hi Chris and thanks for your reasonable feature request. I'll have to leave it in "Open" state until I check following:
  o) I think this was done on purpose
  o) The problem, afair, is already reported.
[8 Sep 2008 8:34] Tonci Grgin
Hi Chris. I was unable to find answers to both of my questions posted above so I'll have to see what Reggie has to say on this.

Verified as described.
[12 Sep 2008 16:42] Reggie Burnett
Chris

Are you trying this with VS 2008?  If so, are you using SP1?  We have already seen some issues actually be bugs in VS.  I just tried to reproduce this with VS 2008 SP1. I created a winforms app (couldn't get code generation to work with web app) and created a dataset.  Then dropped a Sql server table on the surface.    it created a default ctor for the table adapter in the designer file.  I then tried it with what will be 5.2.4 and it behaved identically.  I don't think this is a bug but I'll wait to hear back from you.
[12 Sep 2008 17:12] Chris Robison
Yes, I am using VS 2008 sp1. Yes, there is a default constructor created in the designer file, and that is the problem. In the actual designer interface where you drag stuff and create the table adapters, you can double click on the table adapter name (or the icon next to it) and Visual Studio will generate something like:

namespace LSCMCoreDLL.DataSets 
{
    public partial class CoreDataSet 
    {
    }
}

namespace LSCMCoreDLL.DataSets.CoreDataSetTableAdapters 
{
    public partial class DomainsTableAdapter 
    {  
    }
}

The new file is called <DataSet Name here>.cs. So now in the file system there are two cs files. <DataSet name>.cs and <DataSet name>.Designer.cs.

If there is already a default ctor in the *.Designer.cs file then you can't define one here. Which, is the problem, because I think you should be able to define it here, because the designer file is generated code and the other file will stay the same.
[12 Sep 2008 19:25] Reggie Burnett
Yes, I agree with you but on my system SqlClient does exactly the same thing.
[12 Sep 2008 22:11] Chris Robison
You're right, SqlClient does have the same behavior. I could have sworn the last time I checked it out, I could do something like that. Oh well. I guess that is a visual studio thing. Thanks for trying.

Chris
[31 Aug 2011 20:16] Julio Casal
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php