{"__type":"CountryModel","dt":null,"ds":null,"dtRow":null,"strSQL":{"Capacity":16,"MaxCapacity":2147483647,"Length":0},"iCnt":0,"ConnType":"FP","Code":"AE","Value":"United Arab Emirates"},{"__type":"CountryModel","dt":null,"ds":null,"dtRow":null,"strSQL":{"Capacity":16,"MaxCapacity":2147483647,"Length":0},"iCnt":0,"ConnType":"FP","Code":"AF","Value":"Afghanistan"},{"__type":"CountryModel","dt":null,"ds":null,"dtRow":null,"strSQL":{"Capacity":16,"MaxCapacity":2147483647,"Length":0},"iCnt":0,"ConnType":"FP","Code":"AG","Value":"Antigua and Barbuda"},
これはjsonで返すwebmethodですが、問題は、継承元の基本クラスからのasp.netの戻り値です。これを解決するにはどうすればよいですか? 動作していますが、値を返したくないのでデータが無駄になっていますか?
BaseModel.cs
public string ConnType="";
public datatable dt;
CountryModel.cs:
public class CountryModel:BaseModel{
public List<MenuFunctionModel> AssignList()
{
var _List = new List<MenuFunctionModel>();
foreach (DataRow dr in dt.Rows)
{
_List.Add(new MenuFunctionModel
{
Code = dr["Code"].ToString(),
Title = dr["Title"].ToString(),
Description = dr["Description"].ToString(),
Location = dr["Location"].ToString() + dr["FileName"].ToString()
});
}
return _List;
}
}
ウェブサービス API:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static List<CountryModel> loadCt()
{
CountryModel _Country = new CountryModel();
_Country.SelectAll();
return _Country.AssignList();
}