Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 736835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:39:02+00:00 2026-05-14T07:39:02+00:00

I am outputting a students logged problems by passing the student into the view

  • 0

I am outputting a students logged problems by passing the student into the view and then accessing their problems like this:

foreach (var item in Model.Student.Problems) {

I was wandering how I could sort these items by the ProblemDateTime attribute? I notice when I put a . after Problems there is a OrderByDescending option by I am not entirely sure how to use it?

Any help would be appreciated.

Thanks,

Jon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:39:03+00:00Added an answer on May 14, 2026 at 7:39 am

    I would tend to use a different ViewModel that consist of a Student and Problems as different properties

    public class MyViewModel
    {
        public Student Student { get; set; }
        public IList<Problem> Problems { get; set; }
    }
    

    Then your Controller should be responsible for returning the Student and the correct Problems

    public ActionResult MyAction(int studentID)
    {
        var model = new MyViewModel();
    
        //below is just an example:
        //would be much better if you had a service/repository layer 
        //that you could call to return your information
    
        model.Student = _db.Students.FirstOrDefault(s => d.ID == studentID);
        model.Problems = _db.Problems.Where(p => p.StudentID == studentID)
            .OrderByDescenging(p => p.Date)
            .ToList();
    
        return View(model);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am outputting data to a table like the following: foreach (var attr in
I am currently outputting the url of a particular module like so: $this->view->url(array('controller'=>'index','action'=>'index','module'=>'somemodule')) The
I have problems outputting UTF-8 characters into pdf file with Zend_Pdf. Here is my
I'm stuck outputting data from a table like this. This is a table for
I use TCPDF for outputting an html table, this one in my example is
This zgrep command is outputting a particular field of a line containing the word
mysql is outputting this error You have an error in your SQL syntax; check
Consider the following script for outputting some XML code: var xmlAsString = '<?xml version=1.0?><person><name
I'm outputting html that's all crushed together, and would like to convert it to
The autocomplete is outputting data in this format: <ul class=ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.