By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,680 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,680 IT Pros & Developers. It's quick & easy.

XML and strongly typed datasets

P: n/a
I have a situation in which I have a strongly typed dataset based on the
schema of a xml document. This works great, and OMG I love strongly typed
datasets... ;o)

However, The situation I have has a nested complex type. For example:

<PAGE>
<PAGENUMBER>1</PAGENUMBER>
<PAGETITLE>This is the title</PAGETITLE>
<IMAGES>
<IMAGE NAME="Image1" FILE="image1.jpg" />
<IMAGE NAME="Image2" FILE="image2.jpg" />
<IMAGE NAME="Image3" FILE="image3.jpg" />
</IMAGES>
</PAGE>

(or something to that effect, you get the idea)

Because the <Images> is a Complex type, I can not access it's members
through the dataset. In other words, I can get the page title by saying
"myDataset.Page(index).PAGETITLE", but I can't get a image by saying
something like: "myDataset.Page(index).Images(index2).File"

I know you can manually build relationships in the dataset as long as there
are unique keys in both the <IMAGE> and <PAGE> elements that can be joined
on, (which is what I ended up doing) but it seems like there should be an
easier way.

Thanks a bunch for any advice!

-D
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
D,

You aren't going to be able to access the representation of an image,
because only a small set of types are represented in the dataset. What is
really stored in the dataset is the serialized representation of a type.
The types that are exposed are the types that are frequently used. In the
case of the image, it is the binary representation.

You should be able to save the image to disk, or load the array into
memory and then use one of the static FromXXXX methods on the Image to get
an object representation of that image.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"MC D" <as***@earthtalk.com> wrote in message
news:e7**************@TK2MSFTNGP12.phx.gbl...
I have a situation in which I have a strongly typed dataset based on the
schema of a xml document. This works great, and OMG I love strongly typed
datasets... ;o)

However, The situation I have has a nested complex type. For example:

<PAGE>
<PAGENUMBER>1</PAGENUMBER>
<PAGETITLE>This is the title</PAGETITLE>
<IMAGES>
<IMAGE NAME="Image1" FILE="image1.jpg" />
<IMAGE NAME="Image2" FILE="image2.jpg" />
<IMAGE NAME="Image3" FILE="image3.jpg" />
</IMAGES>
</PAGE>

(or something to that effect, you get the idea)

Because the <Images> is a Complex type, I can not access it's members
through the dataset. In other words, I can get the page title by saying
"myDataset.Page(index).PAGETITLE", but I can't get a image by saying
something like: "myDataset.Page(index).Images(index2).File"

I know you can manually build relationships in the dataset as long as there are unique keys in both the <IMAGE> and <PAGE> elements that can be joined
on, (which is what I ended up doing) but it seems like there should be an
easier way.

Thanks a bunch for any advice!

-D

Nov 20 '05 #2

P: n/a
"MC D" <as***@earthtalk.com> wrote in message
news:e7**************@TK2MSFTNGP12.phx.gbl...
Because the <Images> is a Complex type, I can not access it's members
through the dataset. In other words, I can get the page title by saying
"myDataset.Page(index).PAGETITLE", but I can't get a image by saying
something like: "myDataset.Page(index).Images(index2).File"

I know you can manually build relationships in the dataset as long as there are unique keys in both the <IMAGE> and <PAGE> elements that can be joined
on, (which is what I ended up doing) but it seems like there should be an
easier way.

Thanks a bunch for any advice!


What I do is put another dataset layer on top of the dataset generated by
VS. Then you can create all kinds of overloads and whatnot to give you the
abstraction that you want.

For example,

public class LoginsDataSet : LoginsDataSetVS {
public object Image(int PageIndex, int ImageIndex){} // or whatever.
public int FillBy1(whatever){}
public int FillBy2(whatever){}
}

where LoginsDataSetVS is the class created by VS (in my code I have a
convention of appending VS onto the class name for dataset classes generated
by VS (ie the dataset name in Properties)).

-- Alan
Nov 20 '05 #3

P: n/a
I guess I can see that...

I guess, really, my point is that the dataset can see that there is a
complex type within a complex type, so it knows that one property of the
"PAGE" class will be a collection of "IMAGES", yet when I look at the code
insight there is no collection for "images" _UNDERNEATH_ the <PAGE> level.,
and I was wondering if there is an easier way to do this that I just wasn't
seeing, since it's the first time I've done this.

Thanks for everyones help.

-D

"Alan Pretre" <no@spam> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
"MC D" <as***@earthtalk.com> wrote in message
news:e7**************@TK2MSFTNGP12.phx.gbl...
Because the <Images> is a Complex type, I can not access it's members
through the dataset. In other words, I can get the page title by saying
"myDataset.Page(index).PAGETITLE", but I can't get a image by saying
something like: "myDataset.Page(index).Images(index2).File"

I know you can manually build relationships in the dataset as long as there
are unique keys in both the <IMAGE> and <PAGE> elements that can be joined on, (which is what I ended up doing) but it seems like there should be an easier way.

Thanks a bunch for any advice!


What I do is put another dataset layer on top of the dataset generated by
VS. Then you can create all kinds of overloads and whatnot to give you

the abstraction that you want.

For example,

public class LoginsDataSet : LoginsDataSetVS {
public object Image(int PageIndex, int ImageIndex){} // or whatever. public int FillBy1(whatever){}
public int FillBy2(whatever){}
}

where LoginsDataSetVS is the class created by VS (in my code I have a
convention of appending VS onto the class name for dataset classes generated by VS (ie the dataset name in Properties)).

-- Alan

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.