Reputation: 3453
I have a query that uses three tables: Orders
/ ItemsByCustomers
/ Customers
like this:
dim res = from o in Orders
where o.ItemsByCustomers.Customers.custCity = "Atlanta"
select ...
Apparently, LINQ is querying the database once for each row in the orders
table.
Is there a way of doing the same query better in LINQ without using an explicit SQL command with joins?
Upvotes: 0
Views: 157
Reputation: 2140
for linq to sql, should be something like:
Dim result = From a In dbCtx.Orders
Join b In dbCtx.ItemsByCustomers On b.ItemId Equals a.ItemId
Join c In dbCtx.Customers On c.CusomterId Equals b.CusomterId
Where c.custCity = "Atlanta"
Select a
Upvotes: 1