Trong ứng dụng của tôi, tôi đang sử dụng Khung thực thể.LINQ to EntityFramework DateTime
Bảng My
-Article
-period
-startDate
tôi cần hồ sơ phù hợp =>DateTime.Now > startDate and (startDate + period) > DateTime.Now
Tôi đã thử mã này nhưng bây giờ nó làm việc
Context.Article
.Where(p => p.StartDate < DateTime.Now)
.Where(p => p.StartDate.AddDays(p.Period) > DateTime.Now)
Khi tôi chạy mã của tôi ngoại lệ sau đây xảy ra
LINQ to Entities does not recognize the method 'System.DateTime AddDays(Double)' method, and this method cannot be translated into a store expression.
Loại nào là 'khoảng thời gian'? 'AddDays' là hàm sai nếu nó là' double'. –
loại thời gian là int – Yucel