Translate a query to MVC

Posted on 2012-09-11
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:jakyll
    1 Comment
    LVL 7

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    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.…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now