System.Reflection の MethodInfo と MethodBody クラスを使用してメソッドを呼び出したいのですが、メソッドの名前と本体が SQL サーバーにあります。
SqlConnection con = new SqlConnection(GlobalData.GetConnectionString());
SqlCommand cmd = new SqlCommand("select CodeSnippet from SubMenu where Role_ID='"+GlobalData.RoleID+"' and ChildMenu='"+sender.ToString()+"'", con);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
string codeSnippet = reader["CodeSnippet"].ToString();
Type type = typeof(Helper);
MethodInfo method = type.GetMethod(codeSnippet);
Helper c = new Helper();
method.Invoke(c, null);
}
if (con.State == ConnectionState.Open)
{
con.Close();
}
これで完了です。Microsoft SQL サーバーからメソッド本体が必要です