Accepted answer

You can use the let keyword to scope a variable containing the result of your subquery. However, it depends on the LINQ provider as to whether or not it can understand the command (I'm starting to suspect that may be the case).

var result = (from p in productInQuery
      join o in orderInfoQuery on p.refNo equals o.refNo
      join t in productOutQuery on equals t.productInNo into productIn
      from t in productIn.DefaultIfEmpty()
      let dateOut = (from m in orderInfoQuery where m.refNo == t.refNo select m.processData).FirstOrDefault()
      orderby o.processDate descending
      select new
          modelNo = x.modelNo,
          qty = p.qty,
          dateIn = o.processDate,
          dateOut = dateOut

Related Articles