このクエリは結合と同等ですかLEFT OUTER
?
//assuming that I have a parameter named 'invoiceId' of type int
from c in SupportCases
let invoice = c.Invoices.FirstOrDefault(i=> i.Id == invoiceId)
where (invoiceId == 0 || invoice != null)
select new
{
Id = c.Id
, InvoiceId = invoice == null ? 0 : invoice.Id
}
ベストアンサー1
into ステートメントは必要ありません。
var query =
from customer in dc.Customers
from order in dc.Orders
.Where(o => customer.CustomerId == o.CustomerId)
.DefaultIfEmpty()
select new { Customer = customer, Order = order }
//Order will be null if the left join is null
はい、上記のクエリは確かに LEFT OUTER 結合を作成します。
複数の左結合を処理する同様の質問へのリンク:Linq to Sql: 複数の左外部結合