如何将 Redis 数组 RedisResult 转换为 C# 数组?
How to convert a Redis ArrayRedisResult into a C# array?
我想转换 Redis 返回的数组 table 以便在我的 C# 代码中使用。我怎样才能做到这一点 ?
调试代码后,我可以看到他 returns 一个 ArrayRedisResult
string script = @"return redis.call('HGETALL', @key)";
LuaScript lScript = LuaScript.Prepare(script);
var lLScript = lScript.Load("myServerinformation");
var result = lLScript.Evaluate("myDatabaseInformation", "myKey");
提前致谢
摘自 OP 在某些评论中说的其他答案:
the million dollars question is how to convert it to a type array that
C# will understand?
当您意识到您的问题有一个非常简单的答案时,您会哭泣:ArrayRedisResult
可以转换为很多数组类型:string[]
、bool[]
... Check its source code.
归根结底,这只是关于编写一个显式转换:
var result = (string[])lLScript.Evaluate("myDatabaseInformation", "myKey");
我想转换 Redis 返回的数组 table 以便在我的 C# 代码中使用。我怎样才能做到这一点 ?
调试代码后,我可以看到他 returns 一个 ArrayRedisResult
string script = @"return redis.call('HGETALL', @key)";
LuaScript lScript = LuaScript.Prepare(script);
var lLScript = lScript.Load("myServerinformation");
var result = lLScript.Evaluate("myDatabaseInformation", "myKey");
提前致谢
摘自 OP 在某些评论中说的其他答案:
the million dollars question is how to convert it to a type array that C# will understand?
当您意识到您的问题有一个非常简单的答案时,您会哭泣:ArrayRedisResult
可以转换为很多数组类型:string[]
、bool[]
... Check its source code.
归根结底,这只是关于编写一个显式转换:
var result = (string[])lLScript.Evaluate("myDatabaseInformation", "myKey");