C# 如何添加IEnumerable<;T>;使用redis字典收集数据?

C# 如何添加IEnumerable<;T>;使用redis字典收集数据?,c#,dictionary,redis,stackexchange.redis,cachingframework.redis,C#,Dictionary,Redis,Stackexchange.redis,Cachingframework.redis,我试着跟在后面 var Settings = new RedisSettings("localhost"); public async void SetData< T >(IEnumerable< T > collection, string Key) { RedisDictionary< object, T > mydictionary = new RedisDictionary< object, T >(Settings, typeof

我试着跟在后面

var Settings = new RedisSettings("localhost");
public async void SetData< T >(IEnumerable< T > collection, string Key)
{
    RedisDictionary< object, T > mydictionary = new RedisDictionary< object, T >(Settings, typeof(T).Name);
    //how to add collection data into dictionary
    // i tried like following but failed 
    await mydictionary.Set(new[] { new KeyValuePair< object, IEnumerable< T > >(Key, collection) });
var Settings=new RedisSettings(“localhost”);
公共异步void SetData(IEnumerable集合,字符串键)
{
RedisDictionarymydictionary=新的RedisDictionary(设置,typeof(T).Name);
//如何将集合数据添加到字典中
//我试着跟随,但失败了
wait mydictionary.Set(new[]{newkeyvaluepair>(Key,collection)});
但它无法将值插入redis字典:(
我使用了

您的代码似乎与
StackExchange.Redis
无关。它可能与
ServiceStack.Redis
有关

无论如何,如果您希望使用非商业客户端(如
StackExchange.Redis
)将Redis哈希作为.NET词典处理,我建议您使用依赖StackExchange.Redis的库


RedisDictionary
实现的代码。(参见)

也许我疯了,但是
RedisDictionary
a
StackExchange.Redis
class?O\u O