BrickPile.UI.Areas.UI.Controllers.PagesController.Search C# (CSharp) Method

Search() private method

private Search ( string term ) : JsonResult
term string
return JsonResult
        public JsonResult Search(string term)
        {
            object r;
            using (IDocumentSession session = this.documentStore.OpenSession())
            {
                IQueryable<IPage> result = from page in session.Query<IPage, AllPages>()
                    where page.Metadata.Name.StartsWith(term)
                    select page;

                r = from p in result.ToList()
                    orderby p.Metadata.Name ascending
                    select new {id = p.Id, value = p.Metadata.Name, label = p.Metadata.Name};
            }

            return Json(r, JsonRequestBehavior.AllowGet);
        }