我在使用linq查询时遇到问题。该查询工作正常,没有任何错误,但是我对大于某个日期的条目使用where子句,因此它不起作用。
r.Start Date
中的日期是sql中的日期数据类型,并显示dateAndTime
var dateAndTime = DateTime.Now;
var querythpshols = (from r in db.HolidayRequestForms
where (r.StartDate) >= dateAndTime
group r by r.MonthOfHoliday into g
select new {
Value = g.Key,
Count = g.Sum(h => h.HoursTaken),
MonthName = g.Select(d => d.MonthOfHoliday)
});
var resultthpshols = querythpshols.ToList();
对此的任何帮助将不胜感激。 到目前为止,我得到了全部,但where子句未应用
SQL表:
CREATE TABLE [dbo].[HolidayRequestForm](
[RequestID] [int] IDENTITY(1,1) NOT NULL,
[EmployeeID] [int] NOT NULL,
[StartDate] [date] NOT NULL,
[FinishDate] [date] NOT NULL,
[HoursTaken] [decimal](7, 3) NOT NULL,
[Comments] [nvarchar](256) NULL,
[YearCreated] [int] NOT NULL,
[MonthCreated] [int] NOT NULL,
[DayCreated] [int] NOT NULL,
[YearOfHoliday] AS (datepart(year,[StartDate])),
[Approved] [bit] NULL,
[SubmittedBy] [nvarchar](50) NULL,
[ApprovedBy] [nvarchar](50) NULL,
[WorkWeek] AS ((datepart(dayofyear,(datediff(day,(0),[StartDate])/(7))*(7)+(3))+(6))/(7)),
[MonthOfHoliday] AS (datepart(month,[StartDate])),
[MonthOfHolidayName] AS (datename(month,[StartDate])),