首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

select new{}; 查询结果怎么遍历

2011-12-15 
select new{} 查询结果如何遍历C# code public IEnumerable Graves_QueryPlanView(string areaId){using

select new{}; 查询结果如何遍历

C# code
 public IEnumerable Graves_QueryPlanView(string areaId)        {            using (TombDBContext db = new TombDBContext())            {                var query = from s in db.SubArea                            join p in db.subAreaPosition                            on s.Id equals p.FSubArea into temp                            from p in temp.DefaultIfEmpty()                            where s.FareaId==areaId                            orderby s.SubName ascending                            select new                             {                                s.Id,           //区域编号                                s.SubName,      //区域名称                                s.Boxes,        //区域默认箱数                                s.FareaId,      //大区编号                                MaxNum=db.graveTemp.Where(g=>g.subarea==s.Id).Max(g=>g.gname), //最大编号数                                MinNum=db.graveTemp.Where(g=>g.subarea==s.Id).Min(g=>g.gname), //最小编号数                                AllBox=db.graveTemp.Where(g=>g.subarea==s.Id).Count(), //所有箱数                                posId=(p==null?0:p.pId), //位置编号                return query.ToList();            }        }private void GetDate(){  IEnumerable plan=Graves_QueryPlanView("xxoo");foreache(var item in plan){//这里该如何遍历}}


[解决办法]
你直接返回IEnumerable<>泛型集合就行嘛
之后定义List<db.subAreaPosition> list变量来获值
之后foreach遍历就可以啊

热点排行