Пример #1
0
        public ActionResult Detail(int item)
        {
            //var rels = TermRelationService.Query(r => r.TermId.Equals(item));
            //var post = from p in PostService.Query()
            //           join r in rels
            //           on p.Id equals r.ObjectId
            //           select new
            //           {
            //               p.Id,
            //               p.Author,
            //               p.Title,
            //               p.Excerpt,
            //               p.Content,
            //               Comments = p.Comments.Select(c => new { c.Id, c.Content, c.Author, Commented = c.Commented.ToString() })
            //           };

            var rel   = TermService.QuerySingle(t => t.Id.Equals(item)).Relations.ToList();
            var posts = from p in PostService.Query()
                        join r in rel.Select(r => r.ObjectId)
                        on p.Id equals r
                        select new
            {
                p.Id,
                p.Author,
                p.Title,
                p.Excerpt,
                p.Content,
                Comments = p.Comments.Select(c => new { c.Id, c.Content, c.Author, Commented = c.Commented.ToString() })
            };

            return(Json(posts, JsonRequestBehavior.AllowGet));
        }