Why are typed data tables columns declared "internal"?

My blog has moved.
You can view this post at the following address:
http://www.osherove.com/blog/2003/11/17/why-are-typed-data-tables-columns-declared-quotinternalquot.html
Published Monday, November 17, 2003 1:36 PM by RoyOsherove
Filed under:

Comments

Monday, November 17, 2003 9:58 AM by Scalability and typed datasets

# re: Why are typed data tables columns declared "internal"?

It does make sense. I did run into a problem with this today. A somewhat unfortunate database design that I have inherited uses 64-bit integers for primary keys. So I added code to the OnRowChanged event as follows

Because the id column was a primary key it wasn't possible to specify a null value (codegen:nullvalue), so I couldn't use Isidnull().

So I ended up writing code like this:
if (e.Action == DataRowAction.Add) {
DataRow row = e.Row;
try {
long rowid = row["id"];
}
catch { // type miscast imples that the id is still null
row.id = LongRandom.Get();
}

But I agree that there is no good reason to be able to access the underlying columns, since the property accessors provide all the access you need. It is hard to change the behaviour of datasets though, unless you use the ado.net powertoys, which provide a dataset generator with all definitions declared as virtual (so it's easy to override behaviour). You could easily change this code to make the DataColumns public instead of internal. I recommend if you are using ADO.NET typed datasets you use this dataset generator http://www.gotdotnet.com/community/workspaces/workspace.aspx?id=40d3e800-e2af-4220-a079-66552dd2b825. And see also the book chapter to accompany it:

http://www.adoguy.com/content.aspx?id=samplechapter/chapter1
Monday, November 17, 2003 2:58 PM by Oskar Austegard

# re: Why are typed data tables columns declared "internal"?

See my comment at http://weblogs.asp.net/rosherove/posts/6489.aspx#38042

For the record, I have decided to use a modified version of the ADO Guy's dataset generator. I was momentarily contemplating using a CodeSmith template (http://www.ericjsmith.net/codesmith/) instead, but concluded that I wanted to retain the ability to have VS.NET help me build the XSD files.

Oskar
Monday, November 17, 2003 3:08 PM by Roy Osherove

# re: Why are typed data tables columns declared "internal"?

Oskar: Good choice. Personally I never had the need to access those internal columns. But the solution you chose is definitely a good alternative.