这里是我的Linq to Sql代码,它返回表Product中的产品名称列表。但是我也想从表sale中选择SellDateTime coloumn。请帮助
var result = ( from p in db.Products
where
(
from s in db.SaleDetails
join se in db.Sales
on s.SaleId equals se.Id
where
(
from s2 in db.Sales
where s2.CustomerId == customerId
select s2.Id
).Contains(s.SaleId)
select s.ProductId
).Contains(p.Id)
select p.Name
).ToList();
答案 0 :(得分:0)
这样的事情:
var result = ( from p in db.Products
join s in db.SaleDetails
on p.Id equals s.ProductId
join se in db.Sales
on s.SaleId equals se.Id
where se.CustomerId==customerId
select new
{
p.Name,
se.SellDateTime
}
).ToList();