C#
1public HttpContext baseContext; 2 3private List<Dictionary<string, string>> __区分; 4 public List<Dictionary<string, string>> _区分 5 { 6 get 7 { 8 if (__区分 == null) 9 { 10 var parameters = new Dictionary<string, string>(); 11 parameters.Add("種類", _LoginContext._種類); 12 var data = new List<Dictionary<string, string>>(); 13 using (var connection = new SqlConnection(_LoginContext._接続)) 14 { 15 connection.Open(); 16 using (var command = new SqlCommand()) 17 { 18 var method = MethodBase.GetCurrentMethod(); 19 var text = string.Format("/* [{0}.{1}] */", method.DeclaringType, method.Name) + @" 20 DECLARE @種類 INT; SET @種類 = <D:種類>; 21 select distinct 22 コード, 23 コード名 24 from 25 区分マスタ 26 order by 27 コード 28 "; 29 command.Connection = connection; 30 command.CommandText = hos.Utility.ReplaceSql(text, parameters); 31 command.CommandTimeout = int.Parse(ConfigurationManager.AppSettings["SqlCommandTimeout"]); 32 hos.Utility.SqlLog(Context, command); 33 using (var reader = command.ExecuteReader()) 34 { 35 while (reader.Read()) 36 { 37 var dictionary = new Dictionary<string, string>(); 38 for (var i = 0; i < reader.FieldCount; i++) 39 { 40 var name = reader.GetName(i); 41 var value = reader.GetValue(i).ToString(); 42 dictionary.Add(name, value); 43 } 44 data.Add(dictionary); 45 } 46 } 47 } 48 } 49 __区分 = data; 50 } 51 return __区分; 52 } 53 } 54 55 56 public void GetJson() 57 { 58 var data = _区分(baseContext); 59 var json = JsonConvert.SerializeObject(data); 60 baseContext.Response.ContentType = "application/json"; 61 baseContext.Response.Write(json); 62 }
public void GetJson()内の
[_区分]に赤線が入り、
「実行不可能なメンバー''をメソッドのように使用することはできません。」
と表示されます。
「private List<Dictionary<string, string>> __区分;
public List<Dictionary<string, string>> _区分」
を
「public List<Dictionary<string, string>> _区分()」
にして見て、その処理に合うように編集してみましたが、ダメでした。
回答5件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。