存储字典< string,string>在数据库中 [英] Storing a Dictionary<string, string> in the database
本文介绍了存储字典< string,string>在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在代码的某个时刻,我正在创建类型为 Dictionary< string,string>
的字典,并且我想知道在转换方面将其存储在数据库中的最佳方法是什么将其转换为字符串,然后返回字典.
At some point in my code, I'm creating a dictionary of type Dictionary<string, string>
and I'm wondering what's the best way to store this in a database in terms of converting it to a string and then back to a dictionary.
谢谢.
推荐答案
如果您真的想将完整的字典存储为单个字符串,则可以将字典序列化为JSON(或XML)并将结果存储到数据库中
If you really want to store the full dictionary as a single string, then you could serialize your dictionary to JSON (or XML) and store the result to the database.
这篇关于存储字典< string,string>在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文