asp.net - Running multiple linq queries on single model in one function -


As part of a school project, I am trying to create a simple platform, I integrate integrated with my style I was not able to get it, so I am making the basics myself.

Using the lists, I post the output forms, then the thread, so that it is 3 pages deep. / P>

The problem I am facing is on the first page that I want to get the current count from the database for posts / thread. Because it can turn into a moment's notice I thought I would count on the page load since this project, because it can count 100 ...

throwing errors in the code below Public Sector Index (int page = 1) {ViewBag.Title = "Forums"; Var model = db.forums.OrderBy (x = & gt; x.forumID). Toggle list (page, 15); Agram (var M in the DB. Pharm) {m.postCount = db.threads.Where (t => T. formid == M. paramium & amp; amp; t.threadID == t.parentThreadID). ); M.threadCount = db.threads.Where (T => T. FORMID == m.forumID) .ount (); } View return (model); }

Throw error

  Exception description: System. Unknown Operation Exception: An open deterder already connected with this command, which must be closed first. Source error: Line 20: FOREAC (var m in DB forum) Line 21: {Line 22: m.postCount = db.threads.Where (t = & gt; T. FORMID == M.FORM & amp; amp; T Thread id == t.parentThreadID .ount (); Line 23: m.threadCount = db.threads. There (t = & gt; T. formid == M. paramium). Country (); I recommend making a call against the model, line 24:}    

Sample code:

  foreach (var in the model) {var threads = db.threads.ToList (); M.postCount = Threads Where (t = & gt; T. forgarm == M. forgotten & amp; amp; treadread == t.parentThreadID). Command (); M.threadCount = Threads. Where (t = & gt; T. phoramid == m.forumID). Country (); }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -