Thứ Năm, 13 tháng 2, 2020

Join nhiều điều kiện


var list = (from p in db.xkXuatKhos
                                join ct in db.xkTaiSans on p.MaXK equals ct.MaXK
                                join bh in db.xkBanHangs on p.MaBanHang equals bh.MaBH
                                join bhvt in db.xkBanHang_VatTus on  ( bh.MaBH+"&"+ ct.MaLTS ) equals (  bhvt.MaBH+"&"+  bhvt.MaLTS )
                                join ts in db.tsLoaiTaiSans on ct.MaLTS equals ts.MaLTS
                                join dvt in db.tsLoaiTaiSan_DVTs on ts.MaDVT equals dvt.MaDVT
                                where p.MaXK == maXK
                                select new
                                {
                                    ts.TenLTS,
                                    ts.KyHieu,
                                    dvt.TenDVT,
                                    SoLuongYeuCau=bhvt.SoLuongQuyDoi-bhvt.SoLuongDaXuatKho+ct.SoLuong,
                                    SoLuongThucXuat=ct.SoLuong,
                                    DonGia=ct.DonGia,
                                    ThanhTien=ct.SoLuong*ct.DonGia
                                }).AsEnumerable().Select((p, Index) => new
                                {
                                    STT = Index + 1,
                                    p.TenLTS,
                                    p.KyHieu,
                                    p.TenDVT,
                                    p.SoLuongYeuCau,
                                    p.SoLuongThucXuat,
                                    p.DonGia,
                                    p.ThanhTien
                                }).ToList();

Không có nhận xét nào:

Đăng nhận xét

Cám ơn bạn đã quan tâm đến bài viết của mình nhé!