如何传递参数-字典格式 [英] How to pass parameter in - Dictionary Format

查看:57
本文介绍了如何传递参数-字典格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个方法,该方法获取Class的参数和存储过程的名称

I have wrote a method which get''s parameter of Class , and Stored procedure name

Cmd.Parameters.Add("@C_Id", SqlDbType.Int).Value = UI.C_Id;
Cmd.Parameters.Add("@C_Name", SqlDbType.VarChar, 30).Value = UI.C_Name;



我曾将@C_Id用作奇数代码,但我想作为参数传递

请给建议

谢谢,



i used as @C_Id as Odd Code , but i want to pass as argument

pls give Suggestion

Thanks,

推荐答案

您要保存常用的字符串.您有几种方法.我的首选方法是添加带有静态字符串的constants.cs:

You want to save often used Strings. You have several Approaches. My Preferred Approach is adding a constants.cs with static string:

internal class Constants 
{
  internal static String Id = "@C_Id";
}



您可以稍后致电
使用它



you can use it later by calling

Cmd.Parameters.Add(Constants.Id, SqlDbType.Int).Value = UI.C_Id;



另一种方法是将枚举与ToString()方法一起使用.字典不是最好的方法,因为总是必须首先对其进行初始化.

希望我能帮上忙



Another Approach is using an enum with the ToString() Method. A Dictionary is not the best way, since it always has to be initialized first.

Hope i could help


这篇关于如何传递参数-字典格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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