Linq在哪里遇到麻烦

时间:2014-02-21 19:42:38

标签: c# linq

嗨,我在编写linq查询时遇到了困难。不确定在哪里放置我的Where子句。

using (var ctx = DB.Get())
        {
            Interaction = new BindableCollection<InteractionDTO>(
                ctx.Interactions.Select(
                x => new InteractionDTO
                {
                    Indepth = x.Indepth  
                }
                )
           );
        }

我在哪里放置此代码,或者我如何使用上述语法编写它。 where date>= StartDate.SelectedDate.Value

2 个答案:

答案 0 :(得分:2)

这样的事情应该有效

ctx.Interactions.
   .Where(x => x.date >= StartDate.SelectedDate.Value) 
   .Select(x => new InteractionDTO
            {
                Indepth = x.Indepth  
            })

答案 1 :(得分:2)

尝试这个

            ctx.Interactions
            .where (x=> date >=x.StartDate)
            .Select(x => new InteractionDTO
            {
                Indepth = x.Indepth  
            });
相关问题