String cast to decimal in Where, C# FbConnection

198 Views Asked by At

There is a condition on column written in text:

SomeDecimalColumn = 1234567890 <use your favorite decimal here>

and I need to have a query to a Firebird database to include this condition. Naturally I tried:

//query is a QueryObject of firebird database connection (FbConnection).
// SELECT "A"."SomeDecimalColumn" as C1 
// FROM "MYTABLE" AS "A"
// # SomeDecimalColumn has type DECIMAL(18,0)
var predicate = "SomeDecimalColumn = 1234567890"
query = query.Where(predicate);
//query:
// SELECT "A"."SomeDecimalColumn" as C1 
// FROM "MYTABLE" AS "A" 
// WHERE CAST(1234567890 AS DECIMAL(9,0)) = "A"."SomeDecimalColumn"

It bugs me that it casts string to DECIMAL(9,0) by default. Is there a way to force casting in where to a certain precision, i.e. force DECIMAL(18,0)?

I can't parse this string to separate ColumnName from Value. I don't know a priori what kind of predicate I'm going to get.

0

There are 0 best solutions below