Dapper
Dapper copied to clipboard
Dapper Binding failing with Dynamic Parameters
This issue I have also posted here: https://stackoverflow.com/questions/77902278/why-does-oracle-sql-dapper-not-recognize-these-numbers
Writing a custom Oracle SQL query in .NET using Dapper for dynamic parameters. The field that is giving me an issue is a number(6, 0) field that represents a date field in JD Edwards (JDE Julian Date). In my C# application I have a utility function that converts a date time to JDE Julian Date. Here is the Where clause of the query:
WHERE WR.WLOPST IN :OpStatus AND WO.WASRST IN :WoStatus AND TRIM(WL.MCRP01) IN :Plants AND WC.IWMCUW IN :Depts AND WR.WLMCU IN :WorkCenters AND WR.WLDRQJ >= :DateStart AND WR.WLDRQJ <= :DateEnd AND WT.MEY55OHOLD IN :Holds AND LENGTH(REPLACE(WR.WLAPID, ' ', ' ')) >= :AssetAssigned AND WR.WLDOCO >= :WorkOrderLow AND WR.WLDOCO <= :WorkOrderHigh AND WO.WAVR01 >= :PESNumberLow AND WO.WAVR01 <= :PESNumberHigh AND RT.P1Y55OP IN :OpCodes ORDER BY WR.WLDOCO
I've narrowed down the issue in the where clause to WR.WLDRQJ <= :DateEnd. What is weird is when the date is 02/15/2024 (124046) this query runs fine. When I choose any time past that like 02/16/2024 (124047) I get ORA-01722: invalid number. I validate every datetime value to its Julian Value to make sure the conversion is correct. Furthermore, I can run this in SQL Developer just fine which leads me to believe this may be a dapper issue with dynamic parameters. When debugging I can see what is being assigned to the parameter: