how to achieve counts dashboard using asp.net mvc5 using entity framework code first approace RRS feed

  • Question

  • User-471420332 posted

    I have below table with data

    select * from Table_Card

    Sno    name      status

    1          raj           Card completed
    2          ravi         Cards overdue
    3          rohan     Card due
    4          mazhar   Cards in progress

    Below is select queries
    select count(*) from Table_Card where Status="Card completed"
    select count(*) from Table_Card where Status="Cards overdue"
    select count(*) from Table_Card where Status="Card due"
    select count(*) from Table_Card where Status="Cards in progress"

    Now I got counts like this: 

     Card completed: 1

    Cards overdue: 1

    Card due: 1

    Cards in progress: 1

    This is my actually dashboard to show after admin login using any sample code or your own code to achieve 

    Thursday, August 2, 2018 10:10 AM


  • User475983607 posted

    This question is too open to answer accurately and it is not clear if you have Code First configured.

    I suggest that you set aside time to learn the fundamentals.  The Getting Started tutorials are a good place to start.  It explains the basics needed to move forward with code first and migrations.


    Assuming you already have a Entities created the linq query is very simple.  

    int count = (from tc in DbContext.Table_Card where tc.Status == "Card completed" select x).Count();

    I can't help with the admin View as I cannot see the code.  The standard practice is populating a ViewModel in the Controller and passing the ViewModel to a strongly typed View.  Use Razor syntax to create the HTML markup.  Again these fundamental MVC constructs are explained in the Getting Started tutorial on this site.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 2, 2018 10:31 AM