I want to connect to Redis with ServiceStack.Redis package with c# with below statement.
var redisManager = new RedisManagerPool("127.0.0.1:6380");
var redis = redisManager.GetClient();
redis.Custom("DEL", "DB");
redis.Custom("REDISQL.CREATE_DB", "DB");
redis.Custom("REDISQL.EXEC", "DB", "CREATE TABLE TABLE1(A INT, B TEXT);");
redis.Custom("REDISQL.CREATE_STATEMENT", "DB", "INSERTINTOTABLE1STMT", "INSERT INTO TABLE1 VALUES(?1,?2)");
redis.Custom("REDISQL.EXEC_STATEMENT", "DB", "INSERTINTOTABLE1STMT", 1, "Value1");
redis.Custom("REDISQL.EXEC_STATEMENT", "DB", "INSERTINTOTABLE1STMT", 2, "Value2");
var res = redis.Custom("REDISQL.EXEC", "DB", "SELECT * FROM TABLE1");
Queries are executed fine. Column 'A' of Table1 is defined as an integer. But final command that retrieves all rows from TABLE1 return data of 'A' column as Text because result is RedisText type.
Is there a way to get the results with the same data type of the column ?
So as you mention, the problem is ServiceStack that returns a simple RedisText instead of interpreter the correct data in the redis protocol.
In the example above I am using RediSQL V2 (now know as zeeSQL https://zeesql.com) that returns also the type of the columns.
Moreover, we can return directly JSON, with the correct typing.
More info about all the commands in zeeSQL are here: https://doc.zeesql.com/references
Unfortunately I don't believe there is much we can do, beside a suggestion to the ServiceStack maintainers.
The obvious suggestion is to switch to RediSQL V2 / zeeSQL. We maintain perfect backward compatibility with RediSQL V1.
You just have to prefix your commands with
REDISQL.V1instead of justREDISQL.