首页 > 其他 > 详细

LINQ 嵌套查询

时间:2015-03-10 11:55:33      阅读:181      评论:0      收藏:0      [点我收藏+]

直接代码:

//获取教材下的章跟篇
            IList<Chapter> chapters =
                EntAppFrameWorkContext.DomainModelService.ExtenedService<IEbookManage>()
                    .SearchChapterAndPartByEbookId(ebook.Key);

            Dictionary<Chapter,IList<KeyToChaSec>> dictionary=new Dictionary<Chapter, IList<KeyToChaSec>>();
            //根据章跟篇获取可用的知识点目录关系
            foreach (var chapter in chapters)
            {
                IList<KeyToChaSec> keyToChaSecs =
                    EntAppFrameWorkContext.DomainModelService.ExtenedService<IEbookManage>()
                        .SearchAllValidKeyToChaSecByChapterOrPart(chapter.Key);
                dictionary.Add(chapter,keyToChaSecs);
            }
            var jsons = from dic in dictionary
                        select new
                        {
                            ChapterID=dic.Key.Key,
                            ChapterName=dic.Key.Name,
                            KnowledgePoints=(
                            from keyToChaSec in dic.Value
                            select new
                            {
                                ID = keyToChaSec.KeyPoint.Key,
                                KnowledgePointRef =
                                    @"xhtml/" + keyToChaSec.ChpSect.PositionPage.Key + ".xhtml#kp" + keyToChaSec.KeyPoint.Key,
                                ChapterName = keyToChaSec.ChpSect.Name,
                                ChapterID = keyToChaSec.ChpSect.Key,
                                KnowledgePoint = keyToChaSec.KeyPoint.Name
                            })
                        };

  

LINQ 嵌套查询

原文:http://www.cnblogs.com/ddddai/p/4325470.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!