我有2個查詢是查詢同一個表,但使用不同的參數,我想結合成一體, 查詢1從同一個表合併2個查詢到一個LINQ查詢
//ToDo refactor
int myDayOfWeek = 0;
DateTime dt = DateTime.Today;
myDayOfWeek = (int)dt.DayOfWeek;
var todaysLecture = (from c in _context.LectureGigs.Where(g => g.IsWeekLy == true && (int)g.Days == (myDayOfWeek))
select c).ToList();
//results Ok 1 result
查詢2
var upCommingLecture = _context.LectureGigs
.Include(g => g.Artist).Include(g => g.Genre)
.Where(g => g.DateTime > DateTime.Now && !g.IsCanceled);
//results Ok 2 result
查詢我想創建
var upCommingLecture = _context.LectureGigs
.Include(g => g.Artist).Include(g => g.Genre).Where(g => g.IsWeekLy == true && (int)g.Days == (myDayOfWeek))
.Where(g => g.DateTime > DateTime.Now && !g.IsCanceled);
//Error none but 0 result
我還牛逼裏德本
var upCommingLecture = _context.LectureGigs
.Include(g => g.Artist).Include(g => g.Genre)
.Where(g => g.DateTime > DateTime.Now && !g.IsCanceled && g.IsWeekLy==true &&(int)g.Days==(myDayOfWeek));
//Error none but 0 result
難道你們就不能使用where子句中使用OR條件?這樣你可以把你的言論作爲一個整體嗎? – mahlatse
嗨,在我的查詢中,我希望得到兩個結果(q1和q2 -3項目總數),而不是其中一個查詢的結果。 –