如何在EntityFramework中查找月份之间的数据?

stp*_*evi 0 asp.net-mvc entity-framework-5

我需要显示本月的数据(从月份开始到结束的数据)我知道如何在 MySQL 中执行以下查询

enter code here select  @MonthAmount := IFNULL(sum(AmountReceived), 0.0) as TotoalAmountperMonth  
    from collection 
    where  date_time between DATE_FORMAT(NOW() ,'%Y-%m-01') 
        and LAST_DAY(now() - interval 0 month ) and AgentID=v_agent) as monthamount
Run Code Online (Sandbox Code Playgroud)

但是如何使用实体(lambda 表达式) 我对实体很陌生,当我用谷歌搜索时,我必须获取今天但一个月内的数据?

下面的查询得到了今天数据的结果

enter code here  var newAuctionsResults = repo.FindAllAuctions()
                    .Where(a => a.IsActive == true 
                                || (a.StartTime.Value.Year == todayYear
                                    && a.StartTime.Value.Month == todayMonth
                                    && a.StartTime.Value.Day == todayDay))
                    .ToList();
Run Code Online (Sandbox Code Playgroud)

小智 5

尝试

DateTime date = DateTime.Today;
var newAuctionsResults = repo.FindAllAuctions()
  .Where(a => a.StartTime.Value.Year == date.Year 
    && a.StartTime.Value.Month == date.Month)
Run Code Online (Sandbox Code Playgroud)