Tôi có đoạn code sauLINQ to Entities SqlFunctions.DateDiff không được hỗ trợ
DateTime now = DateTime.UtcNow;
var allItemsOver64 = _inventoryContext.Items.Where(i =>
(SqlFunctions.DateDiff("dd", i.PrimaryInsured.DoB, now)/365.0) >= 65);
IQueryable<Item> items65To69 = allItemsOver64.Where(i =>
(SqlFunctions.DateDiff("dd", i.PrimaryInsured.DoB, now)/365.0) >= 65 &&
(SqlFunctions.DateDiff("dd", i.PrimaryInsured.DoB, now)/365.0) <= 69);
Nhưng khi tôi cố gắng và sử dụng allItemsOver64 do đó Items65To69.Count() tôi nhận được lỗi này
Khái niệm ((((Chuyển đổi (DateDiff ("dd", [10007] .PrimaryInsured.DoB, 26/04/2012 15:03:09))/365)> = 65) Và ((Chuyển đổi (DateDiff ("dd" , [10007] .PrimaryInsured.DoB, 26/04/2012 15:03:09))/365)> = 65)) Và ((Chuyển đổi (DateDiff ("dd", [10007] .PrimaryInsured.DoB, 26/04/2012 15:03:09))/365) < = 69)) không được hỗ trợ.
Tôi đang làm gì sai?
Cảm ơn bạn đã chỉnh sửa Arion. –
Bạn đang sử dụng hệ thống RDBMS nào? –