views:

317

answers:

2

In WPF and SubSonic 2 using Active Record, I was able to bind to properties in rows from one table and easily follow the foreign key references (properties that returned the foreign key row representation) to bind to fields in the foreign key table. With SubSonic 3 and ActiveRecord, I'm not quite sure how to do this (easily) anymore. It looks like the foreign key references return IQueryable(Of T) which does not have a property to get the foreign key row. There is, however, are functions (First and Single) which accomplish what I would like.

For example, let's say I have an Employee table with a foreign key reference to a Department table, in SubSonic 2, I was able to do something like:

In code:

MyGrid.ItemsSource = New EmployeeCollection().Load()

In xaml:

<grid:DataGrid name="MyGrid">
  <grid:DataGrid.Columns>
    <grid:DataGridTextColumn Header="Employee" Binding="{Binding Path=EmployeeName}" />
    <grid:DataGridTextColumn Header="Department" Binding="{Binding Path=Department.DepartmentName}" />
  </grid:DataGrid.Columns>
</grid:DataGrid>

In SubSonic 3, I cannot figure out the equivalent to the binding to the DepartmentName, i.e.

Binding="{Binding Path=Department.DepartmentName}"

How do I accomplish the this in SubSonic 3? Thanks in advanced.

A: 

I beleive in WPF that you should bind a collection to an observable collection - see http://stackoverflow.com/questions/878199/create-a-wpf-observablecollection-from-a-subsonic-2-2-collection

kevinw
A: 

I see two options:

1) Modify the T4 templates to provide the properties you are expecting. This may seem more naturally, but I'm not sure you won't end up with those properties on models where they aren't appropriate.

2) Use the ObjectDataProvider to bind to methods on your models.

Will