如何使用C#将字典保存到数据库中? [英] How to save a dictionary into a database with C#?

查看:116
本文介绍了如何使用C#将字典保存到数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用以下方式将字典保存到数据库中:

I have been using following way to save dictionaries into the database:

  1. 将字典转换为XML.
  2. 将此XML传递到SP(存储过程).
  3. 在SP中使用:

  1. Convert the dictionary to XML.
  2. Pass this XML to a SP(Stored Procedure).
  3. In the SP use:

Select 
    Key1,                   
    Value1
into #TempTable                                      
FROM OPENXML(@handle, '//ValueSet/Values', 1)
WITH 
(                                  
  key1 VARCHAR(MAX),     
  value1 varchar(100)  
)

  • 完成.

  • Done.

    有没有一种方法可以将字典保存到数据库而不将其转换为XML?

    Is there a way to save dictionaries to a database without converting it to XML?

    推荐答案

    这取决于是否...

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