views:

39

answers:

1

Hello, I am using SubSonic with the ActiveRecord template. I like it pretty well so far but can not figure out how to do a join query. I have read this link but the generated class templates it creates does not have anything of type IColumn

Is there something I am missing here? Also, I am using SubSonic 3.0

+2  A: 

You can use simple Linq queries to do joins with Subsonic.

For example:

var products = from p in Product.All()
               join od in OrderDetail.All() on p.ProductID equals od.ProductID
               select p;
Jeremy Seekamp
One question. I'm not too familiar with how Linq works.. Is this doing the join on the database or does it pull down all records and do the join in the C# code?
Earlz
A SQL query is generated from this Linq expression. Product.All() does not hit the database. Actually until the variable products is enumerated the database will remain untouched. When you're first starting out with Linq it's a good idea to run SQL profiler so you can see exactly what's happening. Hope this helps.
Jeremy Seekamp