0

3 つのテーブルを使用するクエリがあります: // 次のOrdersように:ItemsByCustomersCustomers

dim res = from o in Orders 
          where o.ItemsByCustomers.Customers.custCity = "Atlanta"
          select ...

ordersどうやら、LINQ はテーブルの行ごとに 1 回データベースにクエリを実行しているようです。

結合で明示的な SQL コマンドを使用せずに、LINQ で同じクエリをより適切に実行する方法はありますか?

4

1 に答える 1

1

linq to sql の場合、次のようになります。

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
于 2013-09-05T07:05:42.360 に答える