querybuilder
querybuilder copied to clipboard
WhereDatePart error for SQLite
I tried to use WhereDatePart and I saw I had no results even when I have data on the DB, so I get the sqlkata generated SQL and I see for this function you use "cast(? as text)" instead of the integer itself.
I solve it using WhereRaw but I guess this is an issue.
This is What I had before: (this returns no information)
_com.DB.Query(table)
.Where("field", ID)
.WhereNot("Status", "DROPPED")
.WhereDatePart("month", "date", ">=", DateTime.Now.Month)
.OrderBy("date")
.Get<Date>().ToList();
and the sql sqlKata did for this is this (this returns no information)
SELECT * FROM \"table\" WHERE \"field\" = ? AND NOT (\"Status\" = ?) AND strftime('%m', \"date\") >= cast(? as text) ORDER BY \"date\"
This is what I have now (this works!!)
_com.DB.Query(table)
.Where("field", ID)
.WhereNot("Status", "DROPPED")
.WhereRaw("strftime('%m', date) >= " + DateTime.Now.Month)
.OrderBy("date")
.Get<Date>().ToList();
and the sql sqlKata did for this is this (this works!!)
SELECT * FROM \"table\" WHERE \"field\" = ? AND NOT (\"Status\" = ?) AND strftime('%m', \"date\") >= ? ORDER BY \"date\"
Could you share a project that reproduce this issue?
Closing since no enough information to reproduce