我需要创建一个动态查询,其中变量DayOfWeek.Monday
是动态的,我该如何设置?
DataClassesPDataContext pe = new DataClassesPDataContext();
var qry = from p in pe.R
join q in pe.V on p.V equals q.V_
where p.Data < data
where q.I == `v`
where p.Data.DayOfWeek == `DayOfWeek.Monday`
select(p.Q);
return qry.ToList().Average();
答案 0 :(得分:2)
您可以将DayOfWeek
提取到变量
var day = DayOfWeek.Monday;
var qry = ...
where p.Data.DayOfWeek = day
但请注意。如果您对DayOfWeek
Entity Framework