From 908b50cb47c6d7f1f3e8ec15daf34352c56df440 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 7 Apr 2017 10:54:46 -0400 Subject: [PATCH] Don't dispose the db context. --- Project-Unite/Controllers/HomeController.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Project-Unite/Controllers/HomeController.cs b/Project-Unite/Controllers/HomeController.cs index 173dc35..1006bbf 100644 --- a/Project-Unite/Controllers/HomeController.cs +++ b/Project-Unite/Controllers/HomeController.cs @@ -40,16 +40,17 @@ public ActionResult Search(string query) { var result = new SearchResult(); query = query.ToLower(); - using(var db = new ApplicationDbContext()) - { - result.Downloads = db.Downloads.Where(x => x.Name.ToLower().Contains(query) || x.Changelog.ToLower().Contains(query)); - result.ForumTopics = db.ForumTopics.Where(x => x.Subject.ToLower().Contains(query)); - result.Skins = db.Skins.Where(x => x.Name.ToLower().Contains(query) || x.ShortDescription.ToLower().Contains(query) || x.FullDescription.ToLower().Contains(query)); - result.Users = db.Users.Where(x => x.DisplayName.ToLower().Contains(query)||x.Bio.ToLower().Contains(query)||x.Interests.ToLower().Contains(query)||x.Hobbies.ToLower().Contains(query)); - result.WikiPages = db.WikiPages.Where(x => x.Name.ToLower().Contains(query) || x.Contents.ToLower().Contains(query)); - //Holy crap that search was... long. - return View(result); - } + var db = new ApplicationDbContext(); + + + result.Downloads = db.Downloads.Where(x => x.Name.ToLower().Contains(query) || x.Changelog.ToLower().Contains(query)); + result.ForumTopics = db.ForumTopics.Where(x => x.Subject.ToLower().Contains(query)); + result.Skins = db.Skins.Where(x => x.Name.ToLower().Contains(query) || x.ShortDescription.ToLower().Contains(query) || x.FullDescription.ToLower().Contains(query)); + result.Users = db.Users.Where(x => x.DisplayName.ToLower().Contains(query) || x.Bio.ToLower().Contains(query) || x.Interests.ToLower().Contains(query) || x.Hobbies.ToLower().Contains(query)); + result.WikiPages = db.WikiPages.Where(x => x.Name.ToLower().Contains(query) || x.Contents.ToLower().Contains(query)); + //Holy crap that search was... long. + return View(result); + } }