renaming an element in a schema/dataset

  • Thread starter Per Hornshøj-Schierbeck
  • Start date
P

Per Hornshøj-Schierbeck

I read some xml data through a stream, and pass it to a dataset for it to
read. First i initialize the dataset with an xml schema.

The schema matches the data i get from the stream, but i want to change the
name of some of the columns. Normally i would add some mappings to the
dataadapter, but since i'm not using a dataadapter (there is no database
involved - i get the xml data from a webservice) i don't know how.

Is there any way you can define your schema, so it reads the correct data,
but renames the column kinda like this:

<xs:element name="date" type="xs:string" renamed-to="start-date" />

As far as i can see, there is no such attribute on the xs:element - or any
other way to do it? All i want to do, is rename the column name and still
(preferably) keep the relations to other tables/columns, without having to
loop through the dataset creating a new one with different column names.

Thanks!
 
E

Eirik M.

Please note that regenerating the typed data set will loose any annotations
(it would be nice if MS would retain them when regenerating the ds :)

Eirik M.
 
N

Nicole Calinoiu

Eirik,

I have never seen the behaviour you describe. Once I add annotations (or
any other non-designer elements or attributes) to a schema, they stay there
unless I remove them, and every time I generate (whether it's the first time
or not) a typed dataset from a schema with annotations, they get applied
correctly (assuming I specified them correctly <g>). How/when are you
"losing" your?

Nicole
 
P

Per Hornshøj-Schierbeck

Hey Nicole and Erik

Thanks for the input :) I checked out the link Nicole gave me, and couldn't
make it work. I read the headline (duh) seeing it was ment for "typed
datasets". I don't know why i didn't make it typed, now that i do have a
schema so i guess i could change it to that instead - it would make more
sense ;) I guess that is the only way to make the codegen:typedName work?

Thanks again. About the comment Erik had - if i have several tables in my
dataset and i have relations between them, does having the typedName
attribute mean they break?

Per
 
E

Eirik M.

Nicole Calinoiu said:
Eirik,

I have never seen the behaviour you describe. Once I add annotations (or
any other non-designer elements or attributes) to a schema, they stay there
unless I remove them, and every time I generate (whether it's the first time
or not) a typed dataset from a schema with annotations, they get applied
correctly (assuming I specified them correctly <g>). How/when are you
"losing" your?

Sorry, I was wrong about this. Was thinking of something else.

Eirik
 
E

Eirik M.

Per Hornshøj-Schierbeck said:
Hey Nicole and Erik

Thanks for the input :) I checked out the link Nicole gave me, and couldn't
make it work. I read the headline (duh) seeing it was ment for "typed
datasets". I don't know why i didn't make it typed, now that i do have a
schema so i guess i could change it to that instead - it would make more
sense ;) I guess that is the only way to make the codegen:typedName work?

Try this article. It's quite good.

http://www.ondotnet.com/pub/a/dotnet/2003/03/31/typeddatasetannotations.html
Thanks again. About the comment Erik had - if i have several tables in my
dataset and i have relations between them, does having the typedName
attribute mean they break?

See the article mentioned above.

Eirik M.
 

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