Składnia metody Join

IList<byte> p_statuses = new List<byte>(new byte[] { (byte)Status.Statuses.Accepted, (byte)Status.Statuses.Pending }
return db.CLAIM.Join(db.CLAIM_LINE, c => c.ClaimId, l => l.ClaimId, (c, l) => new { Claim = c, ClaimLine = l })
       .Any(x => p_statuses.Contains(x.ClaimLine.StatusId.Value) && x.ClaimLine.InvoiceLineId == invoiceLineId && x.Claim.InvoiceId == invoiceId);
Advertisements

Left join w LINQ

var results = from c in db.CUSTOMER                         
                     join o in db.ORDER
                          on c.CustomerId equals o.CustomerId into joinedCustOrder
                          from order in joinedCustOrder.DefaultIfEmpty()
                      select new
                      {
                         Order = order,
                         Customer = c
                      };