Dataset class in VS2008

  • Thread starter Thread starter AMP
  • Start date Start date
A

AMP

Hello,
I click on Add Data Source and go through all the dialog boxes and
what I get is a class with a bunch of partial classes. I get that.
What I dont understand is why much of the code shows up many times.
I have included a snippet below. You dont have to read it...but this
gets repeated EXACTLY in every partial class.
There are over 10,000 lines in this IDE created class and it looks
like most of it is just repeated.
But I'm not sure, thats why I'm asking.
Thanks,
Mike
Ex:internal global::System.Data.SqlClient.SqlConnection Connection {
get {
if ((this._connection == null)) {
this.InitConnection();
}
return this._connection;
}
set {
this._connection = value;
if ((this.Adapter.InsertCommand != null)) {
this.Adapter.InsertCommand.Connection = value;
}
if ((this.Adapter.DeleteCommand != null)) {
this.Adapter.DeleteCommand.Connection = value;
}
if ((this.Adapter.UpdateCommand != null)) {
this.Adapter.UpdateCommand.Connection = value;
}
for (int i = 0; (i < this.CommandCollection.Length); i
= (i + 1)) {
if ((this.CommandCollection != null)) {
((global::System.Data.SqlClient.SqlCommand)
(this.CommandCollection)).Connection = value;
}
}
}
}
 
Hello,
I click on  Add Data Source and go through all the dialog boxes and
what I get is a class with a bunch of partial classes. I get that.
What I dont understand is why much of the code shows up many times.
I have included a snippet below. You dont have to read it...but this
gets repeated EXACTLY in every partial class.

Hi,

Well the code you posted makes all the sense in the world, it appear
that the class (and I assume all the others too) have a DataAdapter as
a member and a property named Connection, that when it's set it update
all the connections of the commands of the DataAdapter.

I see no problem there.

Maybe if all the classes inherit from a common base and the above
functionality is implemented there then you (or the framework) do not
have to generate it so many times.

But again, I see no problem with that. I do not think you will end
with a much bigger code for that.
 
Back
Top