Reputation: 4479
I've created a dataset using the dataset designer. One of my tables is called Users
and so there is a class called UsersDataTable
. In this class are some properties, namely Connection
. So I created a Partial Class UsersDataTable
, but none of the routines, properties, or variables from the UsersDataTable
class in the designer codebehind file are visible to me.
I'm simply trying to extend the class to add my own routines but leverage the connections and strong typing of the designer-generated class. I've tried creating my own partial classes and testing them to see if I have the problem with other classes and I don't. Only with these dataset designer-generated classes can I not access items in the other half of the partial class.
I'm working in .Net 4. What might I be doing wrong?
Upvotes: 0
Views: 802
Reputation: 4479
It seems as though I've just extended my class using the wrong identifiers:
There is a Namespace
and inside of the namespace is the Partial Public Class
. Therefore my code of:
Partial Public Class myData
Partial Public Class UsersTableAdapter
Public Function DoSomething() As String
Return "Testing..."
End Function
End Class
End Class
was wrong...What I needed was:
Namespace myDataTableAdapters
Partial Public Class UsersTableAdapter
Public Function DoSomething() As String
Return "Testing..."
End Function
End Class
End Namespace
Upvotes: 0
Reputation: 5769
All of the "partial" classes must be declared as such in order for this technique to work, and I'm guessing the Visual Studio DataSet designer isn't generating partial classes:
http://msdn.microsoft.com/en-us/library/wa80x488(v=VS.100).aspx
You might need to inherit from the designer-generated classes instead.
EDIT: Just looked at some VS2010-generated DataSet classes, and they are indeed partial, so assuming you are using .NET 4, yours should be partial as well. I'll investigate further.
FURTHER EDIT:
OK, since the designer creates the *DataTable classes as nested classes within a class that inherits from DataSet, you might need to do the same in your partial class:
public partial class UsersData
{
public partial class UsersDataTable
{
public string Foo { get; set; }
}
}
That seems to work for me.
Upvotes: 1