Typed Dataset Reserved Word: Locale

M

Michael McHenry

If you try to create a typed dataset with a table named Locale, the
dataset generator fails to create a unique name (like by using an
underscore) and instead gives you the following compile-time error:
Property or indexer 'xxx.Locale' cannot be assigned to -- it is read
only

You can resolve this by changing the line in your generated DataSet
class
public LocaleDataTable Locale {
to
public LocaleDataTable Locale_ {

But now your typed DataSet is disconnected from the schema designer,
and that's not much fun.

I haven't tried using one of the third-party generators to see if they
fix this problem. I haven't found any other reference to this problem
on the web, so I'm not confident the other generators are any better
about it. It seems like the VS built-in version ought to be able to
handle it.


I realize that if I were using a DataAdapter, I could create a
TableMapping that allowed me to use a different name in the dataset,
but I am getting the data from an XML file. I realize I could use an
XSL to transform the XML to change that one element name, but I don't
like that solution.

What I cannot find is anything in the designer that allows an XML
element of one name to be represented by a differently named table
property in the generated DataSet.
 
C

Chad Z. Hower aka Kudzu

Michael McHenry said:
If you try to create a typed dataset with a table named Locale, the
dataset generator fails to create a unique name (like by using an

This is a common problem as the Datasets are not well encapselated. Conflicts are common
with naming.
I haven't tried using one of the third-party generators to see if they
fix this problem. I haven't found any other reference to this problem

Which Third party generators have you tried?
on the web, so I'm not confident the other generators are any better
about it. It seems like the VS built-in version ought to be able to
handle it.

Unfortunately the fault is not in the generator, but in the DataSet class.
I realize that if I were using a DataAdapter, I could create a
TableMapping that allowed me to use a different name in the dataset,
but I am getting the data from an XML file. I realize I could use an
XSL to transform the XML to change that one element name, but I don't
like that solution.

What I cannot find is anything in the designer that allows an XML
element of one name to be represented by a differently named table
property in the generated DataSet.

I think you will have to manually map it. Im not sure if there is a property or not on the field
level to do this. There are a lot of properties in there, may of them useful. But I dont use Fill
or the other standard techniques to load my DataSets so I dont have this problem.

You mention you are loading from another XML source. Are you just loading from a stream?
 
C

Cor Ligthert

Michael,

What do you want to say with this message. You can as well not use datanames
as Class, Name, Date etc. we know that. When you are busy with SQL it are
even an endless amount of restricted words.

In other words, what is it that you want to achieve with this message?

Cor
 
M

Michael McHenry

Typed datasets are not always for SQL access. In this case, it is for
XML access.

In SQL, there are reserved words that will not be used for table names.
However, In a correctly designed DataSet generator, words reserved by
the C# language or by inherited properties of the DataSet class should
not be prohibited.

In XML, there are no reserved words.

Largely, this issue is dealt with by the generator adding underscores
to property and method names that would otherwise cause a collision.
This is not the case for a table named "Locale".

I work around this issue by editing the output of the dataset generator
(naming the DataSet Locale DataTable property to Locale_.)


What I hoped to accomplish is to find out if anyone else knew of a
better work around. Like some way you can specify table name mappings
in an XSD file, for example. Or a third-party dataset generator that
is a little more aware.
 
C

Chad Z. Hower aka Kudzu

Michael McHenry said:
What I hoped to accomplish is to find out if anyone else knew of a
better work around. Like some way you can specify table name mappings
in an XSD file, for example. Or a third-party dataset generator that
is a little more aware.

There are several, but many of them dont work with DataSets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top