// Step 8.60 Returns the LOCData, based on using LINQ private LOCData Get(string search) { // This will create a variable db that contains the entity information. using (var db = new ExperienceITDatabaseEntities()) { // Step 8.61: Iterate the ResultsTables. var resultList = db.ResultsTables // Step 8.62: Filter based on the title containing the search value //Student: Update Code Here. .Where(x => true) // Step 8.63: transform the data from ResultsTable to Result .Select <ResultsTable, Result> (t => new Result { //Student: Insert Code Here. }) .ToList(); // Converts to a list // This will return the resultList, and place it in an LOCData object. var data = new LOCData() { results = resultList }; throw new NotImplementedException(); return(null); } }
// Step 8.60: Returns the LOCData, based on using LINQ private LOCData Get(string search) { // This will create a variable db that contains the entity information. using (var db = new ExperienceITDatabaseEntities()) { // Step 8.61: Iterate the ResultsTables. var resultList = db.ResultsTables // Step 8.62: Filter based on the title containing the search value .Where(x => x.Title.Contains(search)) // Step 8.63: transform the data from ResultsTable to Result .Select <ResultsTable, Result> (t => new Result { title = t.Title, createdOn = t.CreateDate, image = new Image() { full = "https://dummyimage.com/275x275/aaaaaa/000000.jpg&text=" + t.Title, square = "https://dummyimage.com/75x75/cccccc/000000.jpg&text=" + t.Title }, links = new Links() { item = "https://dummyimage.com/75x75/aaaaaa/000000.jpg&text=link:" + t.Title, resource = "https://dummyimage.com/275x275/aaaaaa/000000.jpg&text=link:" + t.Title } }) .ToList(); // Converts to a list // This will return the resultList, and place it in an LOCData object. var data = new LOCData() { results = resultList }; return(data); } }