asp.net mvc5(c#)でjsonを作成したいのですが、
dataTableのkey値が取得出来ず、アドバイス頂ければ幸いです。
※.Rows[0]["A"]のAが取得したいのです。
dataTableのままでも良いのですが、循環参照何ちゃらでNGで、
別途方法を考えている所です。
※この方法そのものが破綻していれば申し訳ないです。
やりたいことは連想配列をjsonにしたのを返したいです。
以下、こんなコードを書けるのかな程度です。
c#
1 DataTable result3 = command.execute(param); 2 IList<Dictionary<string, string>> res = new List<Dictionary<string, string>>(); 3 foreach (DataRow item in result3.Rows) 4 { 5 Dictionary<string, string> tmp = new Dictionary<string, string>(); 6 foreach (var t in item.ItemArray) 7 { 8 tmp.Add(????????); 9 } 10 res.Add(tmp); 11 } 12 return Json(res);
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。