我有场景,我必须发送字典作为输入发送为逗号分隔字符串存储过程。字典键和值是否以相同的顺序枚举?
我想知道是否我这样做会有任何可能的情况下,它可能会发送字典中给定的密钥的不正确的值。
static void Main(string[] args)
{
Dictionary<int, string> test = new Dictionary<int, string>();
test.Add(1, "1");
test.Add(3, "3");
test.Add(4, "4");
test.Add(5, "5");
test.Add(2, "2");
JoinTest(test);
}
private static void JoinTest(Dictionary<int, string> test)
{
var keys = string.Join(",", test.Keys);
var values = string.Join(",", test.Values);
}
“作为逗号分隔字符串存储过程” - 如果你在谈论一个SQL Server存储过程,为什么不通过数据跨使用一个类型*设计*保存多个值,如XML或(更好)一个表值参数?为什么要在这里实现字符串绑定,然后强制数据库执行字符串解锁,只是为了获取数据? –
我正在使用postgre sql –