Query Dynamica Linq

0

I need to create a dynamic query, in which the% L DayOfWeek.Monday variable is dynamic, how can I define it?

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();
    
asked by anonymous 03.04.2014 / 10:25

1 answer

1

As long as the DayOfWeek.Monday variable is of the same type as the DayofWeek column, it will work as follows:

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();
    
03.04.2014 / 13:31