Query Dynamic Linq

Asked

Viewed 351 times

0

I need to create a dynamic query, where the DayOfWeek.Monday is dynamic, as I can 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();

1 answer

1


Provided that the variable DayOfWeek.Monday is of the same type as the column DayofWeek will work as per:

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();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.