This project is read-only.
1
Vote

Oracle及Sqlite中DateTime类型Add的Bug

description

var od = db.Orders.FirstOrDefault(o => o.OrderDate == new DateTime(1997, 8, 25) && o.OrderDate.AddHours(3).Hour == 3);

在Sqlite中生成的sql语句:
SELECT t0.[OrderID], t0.[CustomerID], t0.[OrderDate]
FROM [Orders] AS t0
WHERE ((t0.[OrderDate] = @p0) AND ((CAST(STRFTIME('%H', DATETIME(t0.[OrderDate],'FLOOR(3.0) hour')) AS INT)=3)))
LIMIT 0, 1
-- p0:(DbType = DateTime,Value = 1997/8/25 0:00:00)

错误描述:选不出值
解决方法:将DATETIME(t0.[OrderDate],'FLOOR(3.0) hour')中FLOOR函数去掉

在Oracle中生成的sql语句:
SELECT * FROM (SELECT t0."ORDERID", t0."CUSTOMERID", t0."ORDERDATE"
FROM "ORDERS" t0
WHERE ((t0."ORDERDATE" = :p0) AND ((TO_NUMBER(TO_CHAR((t0."ORDERDATE" + interval 'FLOOR(3.0)' Hour),'HH24'))=3)))) WHERE ROWNUM<=1
-- p0:(DbType = DateTime,Value = 1997/8/25 0:00:00)

错误描述:ORA-01867: 间隔无效
解决方法:将 interval 'FLOOR(3.0)' Hour中的FLOOR函数去掉

AddDay、AddMinutes、AddSeconds同理

comments