Passing a WHERE clause for a Linq-to-Sql query as a parameter

前端 未结 2 448
太阳男子
太阳男子 2021-01-28 01:05

This is probably pushing the boundaries of Linq-to-Sql a bit but given how versatile it has been so far I thought I\'d ask.

I have 3 queries that are selecting identical

2条回答
  •  时光取名叫无心
    2021-01-28 01:46

    Yes it is.

    var times = DataContext.EventDateTimes;
    if (cond)
        times = times.Where(time => time.StartDate <= ...);
    
    from row in ... join time in times ...
    

提交回复
热议问题