Hi Danny,
I don't know what exactly your query do. But consider this:
If I want all OrderDetails from german clients, and I want those OrderDetails in which they bought the bigger amount of products, I would want something like this:
select od.*
from [order details] od
inner join orders o on od.orderId = o.orderId
inner join customers c on o.customerId = c.customerId
where c.country = 'Germany'
and od.quantity = (select max(od2.quantity) as maxQuantity
from [order details] od2
inner join orders o2 on od2.orderId = o2.orderId
where o2.customerId = o.customerId)
Which would be written in LINQ2LLBL as:
var q = from od in metaData.OrderDetails
join o in metaData.Orders on od.OrderId equals o.OrderId
join c in metaData.Customers on o.CustomerId equals c.CustomerId
where c.Country == "Germany" && od.Quantity ==
(from od2 in metaData.OrderDetails
join o2 in metaData.Orders on od2.OrderId equals o2.OrderId
where o2.CustomerId == o.CustomerId
select od2.Quantity).Max()
select od;
Please give it a spin with your entities. Or elaborate more so we can help you better (what type of relations are involved?, what do you want to fetch?, what is what you have so far?)