DataRelation

J

John Wood

When you set up a DataRelation, does the data need to already be present in
the table, or will it query dynamically to fill up the data to fulfill the
relationship?

eg.
Customer is the parent table, orders it the child table. Orders is empty.
I navigate from Custom to Order using a DataRelation, will it automatically
send out the SQL to request the related orders?
 
E

EijiTek

The data relation object only creates a relationship between the in-memory
tables. In your example, if the customer table has been populated but the
orders table is empty, calling the GetChildRows() method of any given
DataRow will return an empty array. No data will be automatically
downloaded since the data table has no knowledge of the origin of the data
(ie: did the data come from a database via a DataAdapter or was it manually
added?).
 
J

John Wood

Oh... well datarelations aren't really that useful if you want your database
to be scalable, are they.... You'd think they'd somehow link it up to the
sqlcommandbuilder, given that it has the columns it needs to request the
data.

Thanks.
 
E

EijiTek

Well, I think it really depends on the intent of their application. Keep in
mind that much of the purpose of ADO.NET is to provide a mechanism that
allows for disconnected data access. When working with a connected
environment I've found that it's much better and easier to just query the
data as I need it rather than deal with all of the intricacies of ADO.NET
but a disconnected environment is a totally different beast.

In Web applications I find very little use for the DataRelation class but in
working in environments where I don't have an accessible database or just
need to maintain some data without having a database at all then the
DataRelation class is extremely useful.
 

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