Ya Linq really sweet in that regard. I use it a lot!
See MESSAGE#
1324892 for what I'm doing with it on a treeview (relating the file back to itself.)
With it setup that way, this fills a treeview all by itself no additional code required:
<HierarchicalDataTemplate DataType = "{x:Type prob:cdsContact}"
ItemsSource = "{Binding Path=Children, Mode=TwoWay}">
<cdsc:cdsEditableTextBlock Margin="2,0,0,0"
VerticalAlignment="Center"
Text="{Binding Path=Name, Mode=TwoWay}" />
</HierarchicalDataTemplate>
>>>I think is only works from the child to the parent. You cannot go frmo the parent to the child, I think.
Nope it's bidirectional you get a link to the parent in the child and an EntitySet
collection of children in the parent.
I just wish that the EntitySet that it creates implemented observable. :-( But I just create observable collections in the dbml class that fill themselves when needed.
John
>I watched a Linq video by Scott GU and learned this cool thing about using the Associations that Linq-to-Sql automatically creates in your data model if the proper PK and Forign Key relations exits in you SQL server tables. (You can add them manually in the dmbl designer if they are not in the SQL Server already.)
>
>Anway, this allows you to *directly* refer to the related table, *without* defining the corresponding Joins in your Linq code:
>
>Here's what I mean:
>
>Most commonly demoed way, using Joins in the Linq call:
>>
> var subq = (from p in db.job_info
> join c in db.customers on p.cust_num equals c.custno
> where p.status == 'A'
> orderby c.company
> select c.custno).Distinct();
>
>
>Easier way using Associations in the dbml:
>>
> var subq = (from p in db.job_info
> where p.status == 'A'
> orderby p.customer_source.company
> select p.customer_source.custno).Distinct();
>
>
>
>See the jump?... p.customer_source.company in Orderby and p.customer_source.custno in Select ?
>
>I think is only works from the child to the parent. You cannot go frmo the parent to the child, I think.
>
>
>This would sure keep you from defining the Join dozens of times in an app if you will invest the time to put the Associations in the dbml.