直接上代码: 复制代码 代码如下: public class DP_Provice { public int proviceID { get; set; } public string ProviceName { get; set; } public int ProviceNode { get; set; } public virtual List<DP_City> citySource { get; set; } }
public class DP_City { public int CityNode { get; set; } public string CityName { get; set; } public string ProviceNode { get; set; } }
对以上涉及到的实体类予以赋值,暂时使用一个静态类初始化简单数据: 复制代码 代码如下: public static class DPDataSource { public static List<DP_Provice> InitalData() { List<DP_Provice> source = new List<DP_Provice> { new DP_Provice{ ProviceNode=1, ProviceName="北京", citySource=new List<DP_City>{ new DP_City{ CityNode=11, CityName="北京海淀" }, new DP_City{ CityNode=12,CityName="北京西城" } }}, new DP_Provice{ ProviceNode=2, ProviceName="山东", citySource=new List<DP_City>{ new DP_City{ CityNode=21, CityName="济南" }, new DP_City{ CityNode=22,CityName="德州" } }}, new DP_Provice{ ProviceNode=3, ProviceName="河北", citySource=new List<DP_City>{ new DP_City{ CityNode=31, CityName="石家庄" }, new DP_City{ CityNode=32,CityName="衡水" } }} };