R – How to get related object in Subsonic 3 (ActiveRecord)

activerecordsubsonic3

Given the following:

class Customer
string name
end

class Order
int number
end

I am creating a list of orders. For each order listed, i'd like to display the associated customer name. is there a way to do that via the object graph, or do I have to look it up manually?

Chris

Best Answer

If there is a relation parent-child, Subsonic will honour it, then:

for each o as Order in orders
   Console.WriteLine(o.Customers(0).name)
next
Related Topic