Typed DataSet Navigation (Multiple Tables)

R

rryerson

I don't know if my terminology is correct so please bear with me.

I have a Typed DataSet that contains a number of related Tables. I am
trying to filter the parent table, child table and then traverse a
grand child table with the expected result of the only grand child
records in the data view would be those related to the Parent/Child and
pass through the filter.

I can't seem to do this.

I could possibly be able to extend an answer that is based on Northwind
Orders and order Details. I.e. I want to see only Order Detail records
in the Dataview that pass the filter applied to the master Orders
(Orders.EmployeeId = 6 [I only want to see Order Details that relate to
Employee 5])

If someone could please help me understand the process of setting this
up, I would greatly appreciate it.

..NET 1.1 or 1.0.


Best regards,

Rick
 
R

Rick

A little more Northwind Details - showing the same problem.

The Data Access Logic works fine in returning ALL records of the
associated tables.

I appreciate everyone looking into this... Thanks.

Rick

class Program
{
static void Main(string[] args)
{
// Typed DataSet OrdersData
// 2 DataTables (Orders & OrderDetails
// One Relation (OrdersOrderDetailsRelation Orders =
Parent)
OrdersData ds = new OrdersData();

// Basic Data Access Logic component to populate Orders
DataTable
// with ALL dbo.Orders in Northwind DB
OrdersComponent ordersComp = new OrdersComponent();
// Basic Data Access Logic component to populate
OrderDetails DataTable
// with ALL dbo.[Order Details] in Northwind DB
OrderDetailsComponent orderDetailsComp = new
OrderDetailsComponent();

// fill the Orders DataTable in OrdersData Typed DataSet
ordersComp.Fill(ds);
// fill the OrderDetails DataTable in OrdersData Typed
DataSet
orderDetailsComp.Fill(ds);

// using DataViewSetting to filter Orders table.
(experiment number 5243)
DataViewSetting dvsOrders =
ds.DefaultViewManager.DataViewSettings["Orders"];
dvsOrders.RowFilter = "EmployeeId=6";

//DataView to see the filtered master/parent count
// correctly displays 67
DataView dvOrders = ds.Orders.DefaultView;
Console.WriteLine("Filtered Orders: " +
dvOrders.Count.ToString());

// get a child view to see the filtered children
// should be 168, returns 2155 [total record count in
table]
DataView dvOrderDetails =
ds.Orders.DefaultView.DataViewManager.CreateDataView(ds.Orders.ChildRelations[0].ChildTable);
Console.WriteLine("Child Details: " +
dvOrderDetails.Count.ToString());


/*A FEW MORE TESTS */

// DOES NOT WORK
DataViewSetting dvsOrderDetails =
ds.DefaultViewManager.DataViewSettings["OrderDetails"];
dvsOrderDetails.RowFilter =
"OrderDetails.OrdersOrderDetailsRelation.Orders.EmployeeId = 6";

// ERRORS OUT WITH 'Cannot find column...'
DataView dv = ds.OrderDetails.DefaultView;
// tried several variations, going down or coming up, only
table names, only relation, etc.
dv.RowFilter = "OrderDetails.Orders.EmployeeId = 6";

Console.WriteLine(dv.RowFilter);
Console.WriteLine("Child Details: " + dv.Count.ToString());
}
}
 
R

Rick

Cor,

Thanks for example. However, this really doesn't meet my needs. I can
do this by binding the DataSet to controls (2 data grids) but I need to
be able to do this in code as this is for a windows service.

I need to be able to filter one of the tables and get a view from the
other table(s) that will only contain associated records.

Best regards,

Rick
Rick,

With a version 2.0 typed dataset this is a piece of cake.

With 1.1 I assume that most people have taken the route from the non typed
dataset (it is not changed for nothing in my idea).

I thought that this sample shows a little bit your needs

http://www.vb-tips.com/default.aspx?ID=cb1408ff-030d-4ea8-80b1-af26354b1fa0

I hope this helps,

Cor

I don't know if my terminology is correct so please bear with me.

I have a Typed DataSet that contains a number of related Tables. I am
trying to filter the parent table, child table and then traverse a
grand child table with the expected result of the only grand child
records in the data view would be those related to the Parent/Child and
pass through the filter.

I can't seem to do this.

I could possibly be able to extend an answer that is based on Northwind
Orders and order Details. I.e. I want to see only Order Detail records
in the Dataview that pass the filter applied to the master Orders
(Orders.EmployeeId = 6 [I only want to see Order Details that relate to
Employee 5])

If someone could please help me understand the process of setting this
up, I would greatly appreciate it.

.NET 1.1 or 1.0.


Best regards,

Rick
 
C

Cor Ligthert [MVP]

Rick,

Please keep it with one message thread, now people start answering new
again.

As I read the other message than is the only thing you need the property
"Row"

dr = drv.row; \\\gives the associated row from a drv

I hope this helps,

Cor

Rick said:
Cor,

Thanks for example. However, this really doesn't meet my needs. I can
do this by binding the DataSet to controls (2 data grids) but I need to
be able to do this in code as this is for a windows service.

I need to be able to filter one of the tables and get a view from the
other table(s) that will only contain associated records.

Best regards,

Rick
Rick,

With a version 2.0 typed dataset this is a piece of cake.

With 1.1 I assume that most people have taken the route from the non
typed
dataset (it is not changed for nothing in my idea).

I thought that this sample shows a little bit your needs


http://www.vb-tips.com/default.aspx?ID=cb1408ff-030d-4ea8-80b1-af26354b1fa0

I hope this helps,

Cor

I don't know if my terminology is correct so please bear with me.

I have a Typed DataSet that contains a number of related Tables. I am
trying to filter the parent table, child table and then traverse a
grand child table with the expected result of the only grand child
records in the data view would be those related to the Parent/Child and
pass through the filter.

I can't seem to do this.

I could possibly be able to extend an answer that is based on Northwind
Orders and order Details. I.e. I want to see only Order Detail records
in the Dataview that pass the filter applied to the master Orders
(Orders.EmployeeId = 6 [I only want to see Order Details that relate to
Employee 5])

If someone could please help me understand the process of setting this
up, I would greatly appreciate it.

.NET 1.1 or 1.0.


Best regards,

Rick
 
R

Rick

This method only returns the associated 'rows' for the particular data
row view. But applying a filter to the parent view will contain
multiple rows. I am trying to do this WITHOUT iteration and populating
arrays, collections, etc.

The idea is creating a filter on a parent DataView and then getting a
SINGLE DataView from the child in which contains ALL relating DataRows
/ DataRowViews that essentially pass through the filter.

I would have thought this was possible with a Typed DataSet with
DataRelations.

Consider Northwind. I want to populate a DataGrid with [Order Details]
that are "associated" to orders in which EmployeeId = 5 created.

I don't want to see a DataGrid (or any other controls) with the Orders,
I just want to see and manipulate the order details. (For instance
EmployeeId entered every price with the wrong discount, and I need to
update them, BUT from a single DataView). Also, I want this in a single
DataView, so I don't have to iterate/select the Orders.

Or from the reverse relationship, I would like to see all the orders in
which contain a [order detail] for ProductId = 5. I just want to see
the "associated" Table, in this case here, the Orders (Not Order
Details).

Also, the references to DataGrid are for examples, I am not using ANY
controls what so ever. This is all code, for a Windows Service.

Best regards,

Rick
Rick,

Please keep it with one message thread, now people start answering new
again.

As I read the other message than is the only thing you need the property
"Row"

dr = drv.row; \\\gives the associated row from a drv

I hope this helps,

Cor

Rick said:
Cor,

Thanks for example. However, this really doesn't meet my needs. I can
do this by binding the DataSet to controls (2 data grids) but I need to
be able to do this in code as this is for a windows service.

I need to be able to filter one of the tables and get a view from the
other table(s) that will only contain associated records.

Best regards,

Rick
Rick,

With a version 2.0 typed dataset this is a piece of cake.

With 1.1 I assume that most people have taken the route from the non
typed
dataset (it is not changed for nothing in my idea).

I thought that this sample shows a little bit your needs


http://www.vb-tips.com/default.aspx?ID=cb1408ff-030d-4ea8-80b1-af26354b1fa0

I hope this helps,

Cor

<[email protected]> schreef in bericht
I don't know if my terminology is correct so please bear with me.

I have a Typed DataSet that contains a number of related Tables. I am
trying to filter the parent table, child table and then traverse a
grand child table with the expected result of the only grand child
records in the data view would be those related to the Parent/Child and
pass through the filter.

I can't seem to do this.

I could possibly be able to extend an answer that is based on Northwind
Orders and order Details. I.e. I want to see only Order Detail records
in the Dataview that pass the filter applied to the master Orders
(Orders.EmployeeId = 6 [I only want to see Order Details that relate to
Employee 5])

If someone could please help me understand the process of setting this
up, I would greatly appreciate it.

.NET 1.1 or 1.0.


Best regards,

Rick
 
C

Cor Ligthert [MVP]

Rick,
The idea is creating a filter on a parent DataView and then getting a
SINGLE DataView from the child in which contains ALL relating DataRows
/ DataRowViews that essentially pass through the filter.
If you use a filter with the same keys as the relation, than the relation
has no sense anymore.
AFAIK is it impossible to get returned from a relation direct a datatable
(you can get the childrows by using parent.GetChildRows()). Therefore is
that faking with the dataview.

That sample is the first I gave you. Did you look at it?

Co


Rick said:
This method only returns the associated 'rows' for the particular data
row view. But applying a filter to the parent view will contain
multiple rows. I am trying to do this WITHOUT iteration and populating
arrays, collections, etc.

The idea is creating a filter on a parent DataView and then getting a
SINGLE DataView from the child in which contains ALL relating DataRows
/ DataRowViews that essentially pass through the filter.

I would have thought this was possible with a Typed DataSet with
DataRelations.

Consider Northwind. I want to populate a DataGrid with [Order Details]
that are "associated" to orders in which EmployeeId = 5 created.

I don't want to see a DataGrid (or any other controls) with the Orders,
I just want to see and manipulate the order details. (For instance
EmployeeId entered every price with the wrong discount, and I need to
update them, BUT from a single DataView). Also, I want this in a single
DataView, so I don't have to iterate/select the Orders.

Or from the reverse relationship, I would like to see all the orders in
which contain a [order detail] for ProductId = 5. I just want to see
the "associated" Table, in this case here, the Orders (Not Order
Details).

Also, the references to DataGrid are for examples, I am not using ANY
controls what so ever. This is all code, for a Windows Service.

Best regards,

Rick
Rick,

Please keep it with one message thread, now people start answering new
again.

As I read the other message than is the only thing you need the property
"Row"

dr = drv.row; \\\gives the associated row from a drv

I hope this helps,

Cor

Rick said:
Cor,

Thanks for example. However, this really doesn't meet my needs. I can
do this by binding the DataSet to controls (2 data grids) but I need to
be able to do this in code as this is for a windows service.

I need to be able to filter one of the tables and get a view from the
other table(s) that will only contain associated records.

Best regards,

Rick

Cor Ligthert [MVP] wrote:
Rick,

With a version 2.0 typed dataset this is a piece of cake.

With 1.1 I assume that most people have taken the route from the non
typed
dataset (it is not changed for nothing in my idea).

I thought that this sample shows a little bit your needs


http://www.vb-tips.com/default.aspx?ID=cb1408ff-030d-4ea8-80b1-af26354b1fa0

I hope this helps,

Cor

<[email protected]> schreef in bericht
I don't know if my terminology is correct so please bear with me.

I have a Typed DataSet that contains a number of related Tables. I
am
trying to filter the parent table, child table and then traverse a
grand child table with the expected result of the only grand child
records in the data view would be those related to the Parent/Child
and
pass through the filter.

I can't seem to do this.

I could possibly be able to extend an answer that is based on
Northwind
Orders and order Details. I.e. I want to see only Order Detail
records
in the Dataview that pass the filter applied to the master Orders
(Orders.EmployeeId = 6 [I only want to see Order Details that relate
to
Employee 5])

If someone could please help me understand the process of setting
this
up, I would greatly appreciate it.

.NET 1.1 or 1.0.


Best regards,

Rick
 
R

Rick

If you use a filter with the same keys as the relation, than the relation
has no sense anymore.

It's not a filter on the key. EmployeeId is only part of Orders not
OrderDetails.
(you can get the childrows by using parent.GetChildRows()). Therefore is
that faking with the dataview.
That sample is the first I gave you. Did you look at it?

Yeah, but I don't want to iterate through and creating child views or
getting child rows, because that means I have to hit EVERY parent
record to use these methods, these member would require using a data
transfer object, and thus implement yet another layer of conversion to
and from.

-Rick
Rick,
The idea is creating a filter on a parent DataView and then getting a
SINGLE DataView from the child in which contains ALL relating DataRows
/ DataRowViews that essentially pass through the filter.
If you use a filter with the same keys as the relation, than the relation
has no sense anymore.
AFAIK is it impossible to get returned from a relation direct a datatable
(you can get the childrows by using parent.GetChildRows()). Therefore is
that faking with the dataview.

That sample is the first I gave you. Did you look at it?

Co


Rick said:
This method only returns the associated 'rows' for the particular data
row view. But applying a filter to the parent view will contain
multiple rows. I am trying to do this WITHOUT iteration and populating
arrays, collections, etc.

The idea is creating a filter on a parent DataView and then getting a
SINGLE DataView from the child in which contains ALL relating DataRows
/ DataRowViews that essentially pass through the filter.

I would have thought this was possible with a Typed DataSet with
DataRelations.

Consider Northwind. I want to populate a DataGrid with [Order Details]
that are "associated" to orders in which EmployeeId = 5 created.

I don't want to see a DataGrid (or any other controls) with the Orders,
I just want to see and manipulate the order details. (For instance
EmployeeId entered every price with the wrong discount, and I need to
update them, BUT from a single DataView). Also, I want this in a single
DataView, so I don't have to iterate/select the Orders.

Or from the reverse relationship, I would like to see all the orders in
which contain a [order detail] for ProductId = 5. I just want to see
the "associated" Table, in this case here, the Orders (Not Order
Details).

Also, the references to DataGrid are for examples, I am not using ANY
controls what so ever. This is all code, for a Windows Service.

Best regards,

Rick
Rick,

Please keep it with one message thread, now people start answering new
again.

As I read the other message than is the only thing you need the property
"Row"

dr = drv.row; \\\gives the associated row from a drv

I hope this helps,

Cor

"Rick" <[email protected]> schreef in bericht
Cor,

Thanks for example. However, this really doesn't meet my needs. I can
do this by binding the DataSet to controls (2 data grids) but I need to
be able to do this in code as this is for a windows service.

I need to be able to filter one of the tables and get a view from the
other table(s) that will only contain associated records.

Best regards,

Rick

Cor Ligthert [MVP] wrote:
Rick,

With a version 2.0 typed dataset this is a piece of cake.

With 1.1 I assume that most people have taken the route from the non
typed
dataset (it is not changed for nothing in my idea).

I thought that this sample shows a little bit your needs


http://www.vb-tips.com/default.aspx?ID=cb1408ff-030d-4ea8-80b1-af26354b1fa0

I hope this helps,

Cor

<[email protected]> schreef in bericht
I don't know if my terminology is correct so please bear with me.

I have a Typed DataSet that contains a number of related Tables. I
am
trying to filter the parent table, child table and then traverse a
grand child table with the expected result of the only grand child
records in the data view would be those related to the Parent/Child
and
pass through the filter.

I can't seem to do this.

I could possibly be able to extend an answer that is based on
Northwind
Orders and order Details. I.e. I want to see only Order Detail
records
in the Dataview that pass the filter applied to the master Orders
(Orders.EmployeeId = 6 [I only want to see Order Details that relate
to
Employee 5])

If someone could please help me understand the process of setting
this
up, I would greatly appreciate it.

.NET 1.1 or 1.0.


Best regards,

Rick
 

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