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

本文关键字:CreatedDate 其中 Date1var Date2var 子句 怎么能 where | 更新日期: 2023-09-27 17:53:45

我怎么能写这个与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子句,其中CreatedDate在Date1var &Date2var

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