在c#中存储和检索字典和列表 [英] Store and retrieve dictionary and list in c#

查看:295
本文介绍了在c#中存储和检索字典和列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在SQL server数据库中添加一个字典列表。但是字典,列表是嵌套的,意思是,里面有多个列表。



I want to add a dictionary ,list in SQL server database. But dictionary,list are nested, means, those are have multiple list inside.

Dictionary<int, List<int>> Map_list = new Dictionary<int, List<int>>(); 
           List<List<int>> cover_index_code = new List<List<int>>();





我需要将Map_list存储在一列中,并将cover_index_code存储在一行中的另一列中。并且还需要检索这些值。



请有人建议任何想法完成这个。!



先谢谢你!



I need to store Map_list in a column, and cover_index_code in another column in a single row.And need to retrieve that values also.

Please anyone suggest any ideas to accomplish this.!

Thanks in Advance!

推荐答案

对于这种关系你需要两张桌子。一个用于密钥,另一个用于嵌套列表。您可以在运行时填充字典,也可以使用linq创建字典。这取决于您从db
For this kind of relationship you need two tables. One for the key and another for the nested list. You can populate the dictionary at runtime or you can use linq to create a dictionary. It depends on how you fetch data from the db


这篇关于在c#中存储和检索字典和列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆