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

  • Home
  • SEARCH
  • 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 RTF from a word processor component. This is working well, but
I have a repeater control outputting some HTML. I want a table which outputs
I am trying to find the best practice for generating and outputting html which
I have a small program to order and sort email messages, outputting to a
Is there a way to coax either the h:outputLink or s:link tags into generating
Flowcharting. This ancient old practice that's been in use for over 1000 years now,
Programming Student here...trying to work on a project but I'm stuck. The project is
When outputting user input, do you only use htmlspecialchars() or are there are functions/actions/methods
When outputting images from Photoshop that are over 31 characters I get a compatibility
When outputting links dynamically, I cannot determine the Y-Pos dynamically. It will work find

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.