我如何使用 where 子句来编写它,其中 CreatedDate 位于 Date1var 和 Date2var 之间?



我怎么能写这个与where子句,其中CreatedDate是在Date1var &Date2var吗?

        return _context.Logs.Where(x => x.ApplicationID == applicationId)
            .OrderByDescending(x => x.ID)
            .Take(count)
            .Select(record => new LoggingLogic.entities.Log
            {
                DataL = record.Data,
                LogMessage = record.Message,
                CreatedDate = record.CreateDate,
                ApplicationName = record.Application.Name,
                Environment = record.Application.Environment.EnvironmentName,
                ID = record.ID
            });

Where()更改为Where(x => x.ApplicationID = applicationId && x.CreatedDate >= Date1var && x.CreatedDate <= Date2var)

我假设您想要包含范围

try this

return _context.Logs.Where(x => x.ApplicationID == applicationId && x.CreatedDate >= Date1Var && x.CreatedDate <= Date2Var)
            .OrderByDescending(x => x.ID)
            .Take(count)
            .Select(record => new LoggingLogic.entities.Log
            {
                DataL = record.Data,
                LogMessage = record.Message,
                CreatedDate = record.CreateDate,
                ApplicationName = record.Application.Name,
                Environment = record.Application.Environment.EnvironmentName,
                ID = record.ID
            });

相关内容

  • 没有找到相关文章