Convert IReliableDictionary to IList

前端 未结 2 1142
猫巷女王i
猫巷女王i 2020-12-21 19:29

I have an IReliableDictionary and need to take the items in the dictionary and move them in to an IList to return from my reliable service.

It seems I can\'t do a .T

2条回答
  •  被撕碎了的回忆
    2020-12-21 19:58

    IReliableDictionary (just like an IDictionary) is IEnumerable of key value pairs, so you can go this way:

    public async Task> GetOrdersAsync()
        {
            IReliableDictionary orderItems =
            await this.StateManager.GetOrAddAsync>(CustomerOrderItemDictionaryName);
    
            var list = orderItems.Select(kvp => kvp.Value).ToList();
            return list;
        }
    

提交回复
热议问题