0
我有兩個表面向對象的建模問題
1 = 城市(cityId,CITY(串),CountryId)
2 = 國家(ID,國家或地區名稱(字符串) )
我有兩個類
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")
}
}
}
所有這些代碼運行良好....現在如果我想要一個連接查詢來顯示來自兩個表的數據呢?因爲我只能將數據分配給一個列表中的某個列表?