{"__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从我继承的基类返回值,如何解决这个问题?虽然可以工作,但是数据被浪费了,因为我不想返回值,知道吗?
基本模型.cs
public string ConnType="";
public datatable dt;
国家模型.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();
}