Class 面向对象建模问题
我有两张桌子 1=citiescityId、CITYstring、CountryId 2=CountrySid,CountryNamestring 我有两节课Class 面向对象建模问题,class,relationship,entity-relationship,Class,Relationship,Entity Relationship,我有两张桌子 1=citiescityId、CITYstring、CountryId 2=CountrySid,CountryNamestring 我有两节课 public class CitiesList { public int cityId{ get; set; } public int CountryId{ get; set; } public string CITY { get; set; } public List<CitiesList>
public class CitiesList
{
public int cityId{ get; set; }
public int CountryId{ get; set; }
public string CITY { get; set; }
public List<CitiesList> GetCity()
{
//get city list
//
//
var query = from o in dsResult.Tables[0].AsEnumerable()
select new CitiesList
{
CITYID = o.Field<int>("CITYID"),
CITY = o.Field<string>("CITY")
};
List<CitiesList> lstDisplay = new List<CitiesList>();
lstDisplay.AddRange(query);
return lstDisplay;
}
}
public class CountriesList
{
public int CountryId { get; set; }
public string CountryName { get; set; }
public List<CountriesList> GetDisplayCountryList()
{
//code
//
//
var query = from o in dsResult.Tables[0].AsEnumerable()
select new CountriesList
{
CountryName = o.Field<string>("CountryName"),
CountryId = o.Field<int>("CountryId")
}
}
}
所有这些代码都运行良好……现在,如果我希望联接查询显示两个表中的数据,该怎么办?因为我一次只能将数据分配给一个列表?我认为您需要一个新的数据结构。我正在设想一个类似于多重地图的东西,其中关键是国家,价值是城市列表 数据结构是很好的抽象数据类型,但我认为抽象并不完整。除了列表或地图之外,您还需要其他对象吗