public static KnowHow GetSearchForKnowledge(string searchFor) { KnowHow knowledge = new KnowHow() { caption = "Base de connaissances", headers = new string[] { "Id", "Description", "Créée le", "Modifiée le" }, types = new string[] { "number", "string", "datetime", "datetime" }, props = new string[] { "Id", "Subject", "Creation", "Modification" } }; using (var dbContext = new QuickToDosEntities()) { IQueryable <Knowledge> query; query = dbContext.Knowledges.Where(x => x.Subject.Contains(searchFor)); knowledge.data = query.Select(x => new DataForKnowledge { Id = x.Id, Subject = x.Subject, Creation = x.Creation, Modification = x.Modification, Body = x.Body }).ToList(); } knowledge.data = knowledge.data.OrderByDescending(x => x.Id).ToList(); return(knowledge); }
public static KnowHow GetKnowledge() { KnowHow knowledge = new KnowHow() { caption = "Base de connaissances", headers = new string[] { "Id", "Subject", "Creation", "Modification" }, types = new string[] { "number", "string", "datetime", "datetime" }, props = new string[] { "Id", "Subject", "Creation", "Modification" } }; using (var dbContext = new QuickToDosEntities()) { IQueryable <Knowledge> query = dbContext.Knowledges; knowledge.data = query.Select(x => new DataForKnowledge { Id = x.Id, Subject = x.Subject, Creation = x.Creation, Modification = x.Modification, Body = x.Body }).ToList(); } knowledge.data = knowledge.data.OrderByDescending(x => x.Id).Take(100).ToList(); foreach (DataForKnowledge know in knowledge.data) { know.Files = getFiles(know.Id, "knowledge"); } return(knowledge); }