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 8031209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:01:02+00:00 2026-06-05T01:01:02+00:00

I am working on an asp.net mvc 3 web application , and i have

  • 0

I am working on an asp.net mvc 3 web application , and i have the folloiwng model class inside my .tt folder:-

public partial class Patient
{
    public Patient()
    {
        this.Visits = new HashSet<Visit>();
    }

    public int PatientID { get; set; }
   //code goes here...
    public virtual Gender Gender { get; set; }
    **public virtual ICollection<Visit> Visits { get; set; }**

Then on the Controller class i wrote the following :-

public PartialViewResult ShowOther(int id, int skip, int take )
        {
                ViewBag.take = take;
                Patient patient = repository.GetPatient(id);
               **Visit visit = patient.Visits.OrderByDescending(d => d.Date).Skip(skip).Take(take).SingleOrDefault();**
//code goes here

So my question if wether the following Orderby patient.Visits.OrderByDescending(d => d.Date).Skip(skip).Take(take).SingleOrDefault(); be performed on the application level (which means that all the visits object will be retrived from the database and then the orderby will be done on the application level) OR the Orderby will be performed on the database and only the intended Visit object will be passed to the application?

My repository.GetPatient(id); method looks as follow:-

 public Patient GetPatient(int id)
        {
            return entities.Patients.FirstOrDefault(d => d.PatientID == id);        }

BR

  • 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-06-05T01:01:04+00:00Added an answer on June 5, 2026 at 1:01 am

    Once you access patient.Visits lazy loading will load ALL visits to you application. Everything will be done in your application.

    If you want to load only single visit you try this:

    entities.ContextOptions.LazyLoadingEnabled = false;
    var patient = entities.Patients.FirstOrDefault(d => d.PatientID == id);
    var visit = ((EntityCollection<Visit>)patient.Visists).CreateSourceQuery()
                                                          .OrderByDescending(d => d.Date)
                                                          .SingleOrDefault();
                                                          .
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working ASP.NET MVC web application to manage projects and customers. Now
I am working on an asp.net MVC 3 web application, i have the following
I'm currently working on an Asp.net MVC Web application. In my solution, there're two
I developed an ASP.NET MVC 3 web application and it's working correctly locally, but
Recently i am working on migrating the ASP.NET Web application to MVC. I am
I'm working my way through some ASP.NET MVC reading and I have a web
I have an Asp.Net MVC 2 web application deployed on IIS 7.5 on .Net
i am working on an asp.net MVC web application , currently i am managing
I'm trying to get client validation working on my asp.net mvc 2 web application
I am working on a ASP.NET MVC 2.0 Multi-Presentation web application which would use

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.