It cannot convert:
.Select ( p=> new Purchase() { PurchaseID=p.purchaseid })
for the correct sql statement, in fact it will create an expression tree, but cannot convert it to sql command, you can do something like this:
db.Customer .Where( t=> t.CustID==1)
Edit: Sorry, I did not see your first select statement:
Select( t=> new Customer() { CustName = t.name , Purchases = t.Customer.Purchase... }
linq2entity also cannot handle this (actually any complicated initialization)
But, as I see it, it seems that you have only one client, so why didn’t you fully understand this? in fact it does:
var customer = db.Customer.FirstOrDefault(x=>x.ID == 1)
?
source share