DataTable.Select with nested Parent fields

  • Thread starter Thread starter Chris Forsberg [MVP]
  • Start date Start date
C

Chris Forsberg [MVP]

I want to make a selection from a DataTable using the Select method with the
criteria including a nested parent field. Both of these works fine
(Northwind data):

DataRow[] drs =
ds.Tables["OrderDetails"].Select("Parent(Orders2Details).ShipName LIKE
'A%'");
DataRow[] drs =
ds.Tables["Orders"].Select("Parent(Customers2Orders).CompanyName LIKE
'A%'");

But when I try to...

DataRow[] drs =
ds.Tables["OrderDetails"].Select("Parent(Orders2Details).Parent(Customers2Or
ders).CompanyName LIKE 'A%'");

....it doesn't work! I've looked everywhere without finding any clue on how
the syntax for a nested parent reference would look. Any input would be
appreciated!
 
Hi Chris,

Yes, nested relations doesn't work.
Workaround: create an additional column (in table Orders) details that holds
(Expression property) second level relation
(Parent(Customers2Orders).CompanyName ).

HTH,
 
Ok, thanks Miha!

Miha Markic said:
Hi Chris,

Yes, nested relations doesn't work.
Workaround: create an additional column (in table Orders) details that holds
(Expression property) second level relation
(Parent(Customers2Orders).CompanyName ).

HTH,
--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Chris Forsberg said:
I want to make a selection from a DataTable using the Select method with the
criteria including a nested parent field. Both of these works fine
(Northwind data):

DataRow[] drs =
ds.Tables["OrderDetails"].Select("Parent(Orders2Details).ShipName LIKE
'A%'");
DataRow[] drs =
ds.Tables["Orders"].Select("Parent(Customers2Orders).CompanyName LIKE
'A%'");

But when I try to...

DataRow[] drs =
ds.Tables["OrderDetails"].Select("Parent(Orders2Details).Parent(Customers2Or
ders).CompanyName LIKE 'A%'");

...it doesn't work! I've looked everywhere without finding any clue on how
the syntax for a nested parent reference would look. Any input would be
appreciated!
 
Back
Top