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

AddRange


foreach (var item in List_tn)
            {
                var List_mb = (from tn in db.tnToaNhas
                               join mb in db.mbMatBangs on tn.MaTN equals mb.MaTN

                               join lmb in db.mbLoaiMatBangs on mb.MaLMB equals lmb.MaLMB

                               join tt in db.mbTrangThais on mb.MaTT equals tt.MaTT
                               where tn.MaTN == item.MaTN
                               select new LtData
                               {
                                   TenTN = tn.TenTN,

                                   TongDienTich = db.mbMatBangs.Where(o => o.MaTN == item.MaTN).Sum(o => o.DienTich),

                                   //Đang sử dụng
                                   CanHoThue = tt.ChoThue == false & lmb.MaNMB == 1 ? mb.DienTich : 0,
                                   VanPhongThue = tt.ChoThue == false & lmb.MaNMB == 2 ? mb.DienTich : 0,
                                   KhacThue = tt.ChoThue == false & lmb.MaNMB == 3 ? mb.DienTich : 0,
                                   TongDienTichThue = tt.ChoThue == false ? mb.DienTich : 0,

                                   //Chưa sử dụng
                                   CanHoTrong = tt.ChoThue == true & lmb.MaNMB == 1 ? mb.DienTich : 0,
                                   VanPhongTrong = tt.ChoThue == true & lmb.MaNMB == 2 ? mb.DienTich : 0,
                                   KhacTrong = tt.ChoThue == true & lmb.MaNMB == 3 ? mb.DienTich : 0,
                                   TongDienTichTrong = tt.ChoThue == true ? mb.DienTich : 0,

                               }).ToList();
                ltData.AddRange(List_mb);
               
            }

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é!