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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:04:13+00:00 2026-05-30T02:04:13+00:00

Using MVC3, I have a Student Repository (in a project) and a StudentService (in

  • 0

Using MVC3, I have a Student Repository (in a project) and a StudentService (in another project). In the service I want to create a function that returns all of the students that are in the db table. This is a new way of doing things for me so I’m a bit new. in the GetAllStudents Function below, How could I change the syntax to select all.

In Repository:

      namespace SpeakOut.Data
{
   public class StudentRepository
{
    SpeakOutDataContext context;
    private Table<StudentEntity> table;
    public StudentRepository()
    {
        context = new SpeakOutDataContext();
        table = context.GetTable<StudentEntity>();
    }


    public IQueryable<Student> Select()
    {
        return table.Select(x => new Student
                                {
                                    WNumber = x.WNumber,
                                    CatalogueYear = x.CatalogueYear,
                                    Standing = x.Standing
                                });
    }
}

}

In Services:

   namespace SpeakOut.Services
   {
  public class StudentService
 {
    private StudentRepository repository;
    public StudentService()
    {
        repository = new StudentRepository(); 

    }

    public IQueryable<Student> GetAllStudents()
    {
        return repository.Select().All(x => x.FirstName) ; //**This line is where I don't know how I would call all the students**
    }


}

}

  • 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-30T02:04:13+00:00Added an answer on May 30, 2026 at 2:04 am
    public IQueryable<Student> GetAllStudents()
    {
        return repository.Select();
    }
    

    The code above just a pass-through method. The only benefit is hiding the repository behind the service and perhaps by giving it a better name.

    At this point no data has been retrieved. The collection of data is deferred until IQuerable is being used for example when .ToList() is called. The benefit of leaving it as IQuerablye is that additional filters and sort orders can be added by code further down the line. These additions will be used by the LINQ provider.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using MVC3 - i have a javascript function that uses jQuery get() to
I am using MVC3, and have a Layout file that is common for all
I am using MVC3 on my project. I have a view with tables and
I am using MVC3, EF Model first on my project. I have a view
I am using MVC3, EF Model first on my project. I have a view
I am using MVC3, and have some logic for changing the culture which all
Using: MVC3, Vs2010, and a DbProject In a Solution I have an MVC3 project
I'm using MVC3 with unobtrusive validation. I have a field that the user is
I'm using MVC3 w/ Razor and I have a model that has quite a
I'm playing around with using ASP.NET MVC3 and have a very simple site that

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.