public static IQueryable <BOLichBieuKhongDinhKy> GetAllVisualRun(KaraokeEntities kara, BAN ban)
        {
            int?     khuID  = ban == null ? null : ban.KhuID;
            DateTime dtNow  = DateTime.Now;
            DateTime dt     = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day);
            TimeSpan ts     = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
            var      querya = BOMenuLoaiGia.GetAllVisual(kara);
            var      queryb = from b in GetAllVisual(kara)
                              where
                              ts.CompareTo(b.GioBatDau.Value) >= 0 && ts.CompareTo(b.GioKetThuc.Value) <= 0 &&
                              dt.CompareTo(b.NgayBatDau.Value) >= 0 && dt.CompareTo(b.NgayKetThuc.Value) <= 0 &&
                              (
                b.KhuID == null ||
                b.KhuID == khuID
                              )
                              select b;
            var query = from a in querya
                        join b in queryb on a.LoaiGiaID equals b.LoaiGiaID
                        select new BOLichBieuKhongDinhKy
            {
                MenuLoaiGia         = a,
                LichBieuKhongDinhKy = b
            };

            return(query.Distinct());
        }
 public IQueryable <MENULOAIGIA> GetMenuLoaiGia()
 {
     return(BOMenuLoaiGia.GetQueryNoTracking(mKaraokeEntities));
 }
        public static IQueryable <BOLichBieuDinhKy> GetAllVisualRun(KaraokeEntities kara, BAN ban)
        {
            int?     khuID     = ban == null ? null : ban.KhuID;
            DateTime dt        = DateTime.Now;
            int      dayOfWeek = (int)dt.DayOfWeek;
            TimeSpan ts        = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
            var      querya    = BOMenuLoaiGia.GetAllVisual(kara);
            var      queryb    = from b in GetAllVisual(kara)
                                 where
                                 ts.CompareTo(b.GioBatDau.Value) >= 0 &&
                                 ts.CompareTo(b.GioKetThuc.Value) <= 0 &&
                                 (
                b.KhuID == null ||
                b.KhuID == khuID
                                 )
                                 select b;

            //tim theo ngay trong tuan
            var query1 = from a in querya
                         join b in queryb on a.LoaiGiaID equals b.LoaiGiaID
                         where
                         b.TheLoaiID == 1 &&
                         (
                (dayOfWeek >= b.GiaTriBatDau && dayOfWeek <= b.GiaTriKetThuc && b.GiaTriBatDau < b.GiaTriKetThuc) ||
                (
                    (dayOfWeek >= b.GiaTriBatDau && dayOfWeek <= 6) || (dayOfWeek <= b.GiaTriKetThuc && dayOfWeek >= 0) && b.GiaTriBatDau > b.GiaTriKetThuc
                )
                         )
                         select new BOLichBieuDinhKy
            {
                MenuLoaiGia    = a,
                LichBieuDinhKy = b
            };
            //select a;
            //tim theo ngay trong thang
            var query2 = from a in querya
                         join b in queryb on a.LoaiGiaID equals b.LoaiGiaID
                         where
                         b.TheLoaiID == 2 &&
                         dt.Day >= b.GiaTriBatDau && dt.Day <= b.GiaTriKetThuc
                         select new BOLichBieuDinhKy
            {
                MenuLoaiGia    = a,
                LichBieuDinhKy = b
            };
            //select a;
            //tim theo ngay trong nam
            var query3 = from a in querya
                         join b in queryb on a.LoaiGiaID equals b.LoaiGiaID
                         where
                         b.TheLoaiID == 3 &&
                         b.GiaTriBatDau == dt.Day && b.GiaTriKetThuc == dt.Month
                         select new BOLichBieuDinhKy
            {
                MenuLoaiGia    = a,
                LichBieuDinhKy = b
            };

            //select a;
            return
                (from a in query1.Union(query2).Union(query3).Distinct() select a);
        }