日期:2014-05-17  浏览次数:20743 次

linq to dataset 如何 成list
  struct Person
        {
            public string id;
            public string name;
            public string age;
            public string city;
        }

   var results = from u in ds.Tables[0].AsEnumerable()
                
                      select new
                      {
                         
                            ID = u.Field<string>("ID").ToString().Trim(),
                            Name = u.Field<string>("Name").ToString().Trim(),
                            Age = u.Field<string>("Age").ToString().Trim(),
                            City = u.Field<string>("City").ToString().Trim(),



                      };
        List<Person> listcity = results.ToList();   //这里 提示无法将类型转换 错误 .该怎么写 

------解决方案--------------------
不要使用匿名类

var results = from u in ds.Tables[0].AsEnumerable()
                
                      select new Person
                &