sventevit
sventevit

Reputation: 4816

Add partial class to TableAdapter

I use Visual Studio 2008, .NET 3.5

In my project I have a DataSet called SubCategory. In it is a SubCategoryTableAdapter, with some methods, added in designer with right click -> add query. I can use these methods on my page in a ObjectDataSource object.

Now I would like to add my own method (for select) so that I could use it in ObjectDataSource object. I want to write this method by my self (and not in designer with right click -> add query). If I look into the code of SubCategory dataset, I can create partial class for SubCategory dataset but not for SubCategoryTableAdapter.

How can I make partial class for SubCategoryTableAdapter?

(I'd like to write my own select method because I'd like to show at least one record in my datagrid, even if there is no rows in the table. So if select statement returns 0 rows I want to just add new row with null values in it).

Upvotes: 1

Views: 2586

Answers (2)

sventevit
sventevit

Reputation: 4816

I can add partial class to my TableAdapter but in it's own file (class1.cs). So this way it works.

I just wonder why I can't do it with right click -> show code on dataset designer. It doesn't matter where I click I always get this code:

namespace WebApplication1.MyMoney.DAL {


    public partial class SubCategory {

    }
}

So always just partial class for DataSet and not for TableAdapter.

John, did you type in code for partial class DimCustomerTableAdapter (including using statement) or did it autogenerate?

Upvotes: 0

John Saunders
John Saunders

Reputation: 161821

In the DataSet designer, right-click a TableAdapter and choose "View Code".

alt text

alt text

Upvotes: 2

Related Questions