Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当CreatedDate位于Date1var&;之间时,如何使用where子句编写此代码;Date2var?_C#_Linq - Fatal编程技术网

C# 当CreatedDate位于Date1var&;之间时,如何使用where子句编写此代码;Date2var?

C# 当CreatedDate位于Date1var&;之间时,如何使用where子句编写此代码;Date2var?,c#,linq,C#,Linq,当CreatedDate介于Date1var和Date2var之间时,如何使用where子句编写此代码 return _context.Logs.Where(x => x.ApplicationID == applicationId) .OrderByDescending(x => x.ID) .Take(count) .Select(record => new LoggingLogic.e

当CreatedDate介于Date1var和Date2var之间时,如何使用where子句编写此代码

        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
            });
试试这个

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
            });
return\u context.Logs.Where(x=>x.ApplicationID==ApplicationID&&x.CreatedDate>=Date1Var&&x.CreatedDate x.ID)
.记(数)
.选择(记录=>new LoggingLogic.entities.Log
{
DataL=记录。数据,
LogMessage=record.Message,
CreatedDate=record.CreateDate,
ApplicationName=record.Application.Name,
环境=record.Application.Environment.EnvironmentName,
ID=record.ID
});

将您的
Where()
更改为
Where(x=>x.ApplicationID=ApplicationID&&x.CreatedDate>=Date1var&&x.CreatedDate谢谢。如果Date1var和Date2Var是同一个日期呢?它的类也大于或等于,所以它也应该工作:)