public List<BAIVIET> LayBaiVietMoiNhatTheoChuyenMuc(int MaChuyenMuc) { List<BAIVIET> list = new List<BAIVIET>(); using (LinQDataContext db = new LinQDataContext(global::DAOAuction.Properties.Settings.Default.webdoantruongConnectionString)) { ISingleResult<BAIVIET_LayTopBaiVietMoiNhatTheoChuyenMucResult> lp = db.BAIVIET_LayTopBaiVietMoiNhatTheoChuyenMuc(MaChuyenMuc); foreach (BAIVIET_LayTopBaiVietMoiNhatTheoChuyenMucResult bv in lp) { //BAIVIET_LayBaiVietMoiNhatResult bv = temp[i]; BAIVIET var1 = new BAIVIET(); var1.MaBaiViet = bv.MaBaiViet; var1.TieuDe = bv.TieuDe; var1.NoiDung = bv.NoiDung; var1.MaLoaiBaiViet = bv.MaLoaiBaiViet; var1.NgayDang = bv.NgayDang; var1.HinhAnh = bv.HinhAnh; var1.TomTat = bv.TomTat; if (bv.CapNhat != null) var1.CapNhat = (DateTime)bv.CapNhat; list.Add(var1); } try { // Save the changes. db.SubmitChanges(); } // Detect concurrency conflicts. catch (ChangeConflictException) { // Resolve conflicts. db.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges); } } if (list.Count > 0) return list; else return null; }