473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XML and strongly typed datasets

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
3 1057
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Job Lot | last post by:
I am confused how strongly typed dataset is different from un-typed dataset. Is there any good link explaining pros and cons of both? Which one should be used preferably?
3
by: MC D | last post by:
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...
7
by: Jeff | last post by:
I want to remote several strongly typed datasets and I don't want to distribute the assemblies. I wish to create interface assemblies for these datasets but I don't know where to start. I've...
2
by: David | last post by:
I have been developing applications with Java for quite a while but I am new to .NET development. I am trying to learn the ".NET way" of creating Strongly Typed Objects from a database. The...
1
by: HardBap | last post by:
I've created a strongly typed DataSet (Customers.xsd) using the xsd.exe tool. I want to be able to access fields using ds.Customer.CompanyName. The problem is when I return this DataSet from a...
0
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The...
1
by: herbert | last post by:
Does VS.2005 support strongly typed datasets between PocketPC and Web Services? I have a project stalled and must decide whether to wait for VS.2005 or go back to untyped DataSets. thanks...
1
by: Mike P | last post by:
I have been trying out using strongly typed datasets in VS 2005, and I have to say that I don't like them...they produce loads of auto-generated code, and I would much rather create a single class...
1
by: Chris | last post by:
I have started using strongly typed datasets as the basis of my data access layer. They work well but can be a bit fiddly when adding columns. I have a column which refuses to "change". It is an...
4
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.