小编edd*_*223的帖子

如何将 Redis ArrayRedisResult 转换为 C# 数组?

我想转换由 Redis 返回的数组表以在我的 C# 代码中使用。我怎样才能做到这一点 ?

调试代码后,我可以看到他返回了一个 ArrayRedisResult

string script = @"return redis.call('HGETALL', @key)";
LuaScript lScript = LuaScript.Prepare(script);
var lLScript = lScript.Load("myServerinformation");
var result = lLScript.Evaluate("myDatabaseInformation", "myKey");
Run Code Online (Sandbox Code Playgroud)

预先感谢

c# arrays lua redis stackexchange.redis

3
推荐指数
1
解决办法
1402
查看次数

如何返回 IQueryable<T>

有人能告诉我如何退货吗IQueryable<T>

我正进入(状态 :

无法将类型隐式转换System.Linq.IQueryable<object>System.Linq.IQueryable<TType>. 存在显式转换(您是否缺少强制转换?)

先感谢您

代码:

public IQueryable<TType> ExecuteScript<TType>(string script, object parameters) where TType : class, new()
{
        string typeName = String.Empty;

        LuaScript lScript = LuaScript.Prepare(script);
        var lLScript = lScript.Load(Context.Server());

        //Converts returned result into a string array. 
        var result = (string[])lLScript.Evaluate(Context.Database(), parameters); 

        if (result.Any())
        {
            _dataValue = new SortedDictionary<string, string>();
            int i=0;

            while(i < result.Count())
            {
                _dataValue.Add(result[i], result[i+=1]);
                i++;
            }
        }

        IQueryable<object> query = _dataValue.AsQueryable().Select(r => r.Value);            

        return query;                    
    }  
Run Code Online (Sandbox Code Playgroud)

c# linq

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×2

arrays ×1

linq ×1

lua ×1

redis ×1

stackexchange.redis ×1