Translate a query to MVC

Posted on 2012-09-11
Medium Priority
Last Modified: 2012-09-12
I am new to MVC4 and uncertain how to implement this query into my MVC "world" any tips?  Basically trying to do multi table lookups and display data... simple stuff

SELECT     lcEntries.entry_id, lcEvents.entered_at AS EventEnteredAt, lcEventLookUps.eventType AS Description, lcEvents.scanner_at AS Location,
                      lcEvents.punit AS [PERSON-UNIT], lcEvents.tote_id AS eventstote_id, lcEntries.container_id, lcEvents.orl AS [Rack Location],
                      lcEvents.notes AS Notes
FROM         lcEventLookUps RIGHT OUTER JOIN
                      lcEvents ON lcEventLookUps.eventID = lcEvents.event_type LEFT OUTER JOIN
                      lcEntries ON lcEvents.entry_id = lcEntries.UUID
WHERE     (lcEntries.entry_type = N'specimen') AND (lcEntries.entry_id = N'3')
ORDER BY EventEnteredAt
Question by:Dan Flood
1 Comment

Accepted Solution

gopaltayde earned 2000 total points
ID: 38390076
If I understood your simple stuff correctly then -
1. Add a controller to your MVC project, lets say MyController.
2. Create a POCO (ie a class) Entity to hold the result of above query. Add properties to this class.
3. In the Index() method of MyController initialize the List<POCOEntity> and populate the result there.
4. Pass this list to View.
5. Right click on Index() method and add a strongly typed (of PCOCO) view to the solution and select scaffolding template as List.
6. Run the project and see the output.

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question