views:

49

answers:

1

When messing with the Subsonic 3.0 Northwind stuff:

var product = Product.SingleOrDefault(x => x.ProductID == 1);

I found the following was possible, but not workable) using intellisense:

var product = Product.SingleOrDefault(x => x.OrderDetails == 1);

OrderDetails as a member of Product, is an IQueryable. I guess I'm new to LINQ, but I was wondering how to use this member? Everytime I try to get info out of this I get an error. Could someone give me an example of how to use the OrderDetails member of Product? And perhaps throw the results in a databind to a Gridview?

Look at the following code and tell me what I'm doing wrong:

 var products = from od in OrderDetail.All()
                   join p in Product.All() on od.ProductID equals p.ProductID
                   select od;

I get the following error:

Object of type 'System.Single' cannot be converted to type 'System.Decimal'.
+1  A: 

The IQueriable members that are exposed by SubSonic are your Foreign Keys. You could use them in the following manner.

 Product.SingleOrDefault(x => x.ProductID == 1).OrderDetails.ToList()
runxc1 Bret Ferrier