我对该查询有疑问:
select SanPham.*,TenSX
from SanPham join NhaSanXuat on SanPham.MaSX = NhaSanXuat.MaSX
where GETDATE()- NgayNhap < 15
order by NgayNhap,MaSP desc
我似乎有一个问题:where getdate() - Ngaynhap < 15
这是 linq 查询:
var sp = db.SanPhams.Join(db.NhaSanXuats, masp => masp.MaSX, mansx => mansx.MaSX,
(masp, mansx) => new { SanPham = masp, NhaSanXuat = mansx })
.Where(ngaynhap=>DateTime.Now.Day - db.SanPhams.Select(n=>n.NgayNhap.Value.Day))
.OrderByDescending(nhap => nhap.SanPham.NgayNhap)
.ThenByDescending(masp => masp.SanPham.MaSP)
.Select(s => s.SanPham);