473,385 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to add Method to Inherited Typed DataSet

Joe
Hi

I have a typed dataset and I want to add a method to modify a value in the
datarow.
I want to inherit from the class so if the XSDchanges I would lose my code
when the class regenerates

This is what I am trying with no luck is below. I cannot see JobID in
intellisense after I inherit.
I assume due to it being private

What is the best what to add this method to modify a value in a row?

Thanks

public class JobClass : Schedule

{
public void GenerateNewID()

{

JobID = System.DateTime.Now.Ticks.ToString();

}

}
Genarated Class from XSD
public partial class Schedule : System.Data.DataSet {
private JobsDataTable tableJobs;

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Data.Design.TypedDataSetGenerator",
"2.0.0.0")]
public partial class JobsRow : System.Data.DataRow {
private JobsDataTable tableJobs;
[System.Diagnostics.DebuggerNonUserCodeAttribute()]

internal JobsRow(System.Data.DataRowBuilder rb) :

base(rb) {

this.tableJobs = ((JobsDataTable)(this.Table));

}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]

public string JobID {

get {

try {

return ((string)(this[this.tableJobs.JobIDColumn]));

}

catch (System.InvalidCastException e) {

throw new System.Data.StrongTypingException("The value for column \'JobID\'
in table \'Jobs\' is DBNull.", e);

}

}

set {

this[this.tableJobs.JobIDColumn] = value;

}

}

}

}
Jul 30 '06 #1
2 2357

"Joe" <hc******@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi

I have a typed dataset and I want to add a method to modify a value in the
datarow.
I want to inherit from the class so if the XSDchanges I would lose my code
when the class regenerates

This is what I am trying with no luck is below. I cannot see JobID in
intellisense after I inherit.
I assume due to it being private

What is the best what to add this method to modify a value in a row?

First of all, you're going about this the wrong way. DataSets are generated
as partial classes precisely so that you don't have to inherit them to
extend them. Just add your custom code and methods to a different,
non-generated file that contains additional code for the dataset class.
When the DataSet is regenerated, your hand-written extensions are not
overwritten, and are compiled into the DataSet class. That's what partial
classes are for.

Second, I'm not sure what your particular problem is. But trust me, doing
this with partial classes a whole lot easier and more elegant than doing it
with inheritence.

David
Jul 30 '06 #2
Hello David Browne" davidbaxterbrowne no potted,

David is right, Microsoft doesn't want you to inherit Typed DataSets[1].
In the partial class (which you can have the designer create for you if
you hit F7 when you're in the TDS editor), add a nested class (with the partial
keyword) in your typed dataset and you're set. If you can't figure out how
to make that work, let us know and we'll cruft up a sample.

[1] http://adoguy.com/viewrant.aspx?id=1482

Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
"Joe" <hc******@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Hi

I have a typed dataset and I want to add a method to modify a value
in the
datarow.
I want to inherit from the class so if the XSDchanges I would lose my
code
when the class regenerates
This is what I am trying with no luck is below. I cannot see JobID in
intellisense after I inherit.
I assume due to it being private
What is the best what to add this method to modify a value in a row?
First of all, you're going about this the wrong way. DataSets are
generated as partial classes precisely so that you don't have to
inherit them to extend them. Just add your custom code and methods to
a different, non-generated file that contains additional code for the
dataset class. When the DataSet is regenerated, your hand-written
extensions are not overwritten, and are compiled into the DataSet
class. That's what partial classes are for.

Second, I'm not sure what your particular problem is. But trust me,
doing this with partial classes a whole lot easier and more elegant
than doing it with inheritence.

David

Jul 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Levinson [mcsd] | last post by:
I guess I would have to know what you mean by "not being able to edit the forms". Does this mean you get an error in the designer when you try to display an inherited form? Does this mean the...
1
by: Job Lot | last post by:
I am confused how strongly typed dataset is different from un-typed dataset. Is there any good link explaining pros and cons of both? Which one should be used preferably?
0
by: Ryan Shaw | last post by:
I have a typed dataset which I inherit in a Business Object. I want to add an element when the Business Object is Serialized. public class OrderBLL:OrderMDL /OrderMDL is a typed dataset...
0
by: Henry | last post by:
Dear Group: A question regarding the behavior of the Visual Studio.NET. When I drag the "Customers" table in "Northwind" database on Server Explorer to my web page, then select the DataAdapter...
3
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong...
11
by: MurdockSE | last post by:
Greetings. My Situation: // I have an .xml file that I am reading into a dataset in the following code - DataSet ds = new DataSet("MyDataset"); ds.ReadXml(@"c:\data\"+cmyxmlfilename);
4
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard......
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
4
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.