Sign in
Smart Client Data
This blog describes some of the Data features specific to Smart Clients. This includes Windows Forms, Devices and Visual Studio Tools for Office. The Smart Client Data team, AKA VB Data, is responsible for features such as the Data Sources Window, Typed
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Tags
Blogicles
Occasionally Connected Data
Post Whidbey Thinking
Presentations
Whidbey Q & A
Archive
Archives
August 2006
(1)
April 2006
(2)
February 2006
(3)
November 2005
(5)
October 2005
(3)
September 2005
(2)
August 2005
(6)
July 2005
(4)
June 2005
(6)
Why is my column named _Region in the Typed DataSet?
MSDN Blogs
>
Smart Client Data
>
Why is my column named _Region in the Typed DataSet?
Why is my column named _Region in the Typed DataSet?
SmartClientData
14 Oct 2005 4:49 PM
Comments
2
One quirk you'll find when making a typed DataSet with a column or table named "Region" is that the generated code produces a property called "_Region".
What's up with that? If you read
Raymond Chen's blog
, you already have a pretty good guess: Backward compatability.
In previous versions of Visual Studio, we did the same thing. Why did we do it back then? When we generated a typed DataSet, we ask the Code DOM provider (a generic way of producing semantically equivalent code in multiple languages) if a property name is a valid identifier. This is important so that when you have a column named "Class", we generate "_Class" and the DataSet still compiles. Before Visual Studio 2005, Code DOM provider told us that "Region" was not a valid identifier, so we helpfully fixed up the to be "_Region". The catch is, "Region"
is
a valid identifier in VB. In the latest version, the Code DOM was fixed to answer the question correctly.
All is good so far - a bug got fixed in the product, so everyone should be happier, right?. Until you migrate your VS 7.1 DataSet with a column called "Region" to VS 8.0 and regenerate the designer code. The result is that all of your code which referenced _Region is no longer valid. Life isn't so good now. In the end we decided that the best thing to do was special-case the name in the generator so that compatability would be maintained. Since there's no difference between "old" DataSets and "new" ones, people writing new code still get to see this (very minor and rare) oddity. Such is the price we pay for compatability
Bonus trivia
: We detect this case for another name: "ExternalSource" also gets a free underscore in the DataSet generator.
- Ryan Cavanaugh
2 Comments
Blog - Comment List MSDN TechNet
Comments
Loading...
Leave a Comment
Name
Comment
Please add 6 and 5 and type the answer here:
Post