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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:54:23+00:00 2026-05-23T11:54:23+00:00

I want a controller action ProfessorStatus which queries Professor table and returns list of

  • 0

I want a controller action “ProfessorStatus” which queries “Professor” table and returns list of active professors for a particular school.

Here is the controller action I have, I am struggling with parameterizing the “School” columns

 public ActionResult ProfessorStatus(string schoolType) 
    { 

        var activeProfessors = (from p in prof.ProfessorTable.Where(a => a.Engineering.Value == true) 
                              group p by p.ProfessorID into g 
                              select g.Key).ToList(); 

        return View(activeProfessors); 
    }

Now, In the above controller action. Instead of hard coding “Engineering” I want to parameterize it with “schoolType”.

So if I pass schoolType = Medicine Then the controller will display professors from medicine school and so on for other school types.

How can I avoid hardcording here? Thanks in advance.

  • 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-23T11:54:24+00:00Added an answer on May 23, 2026 at 11:54 am

    If you are not in a position to redesign your whole database and the systems that use it, you can still get around this by using expressions.

    public ActionResult ProfessorStatus(string schoolType) {
      Expresison<Func<Professor, bool>> filter;
      switch (schoolType) {
        case "Engineering":
          filter= a => a.Engineering.Value == true;
          break;
        default:
          throw new Exception("Unknown SchoolType - " + schoolType);
      }
      var activeProfessors = (from p in prof.ProfessorTable.Where(filter)
         group p by p.ProfessorID into g
         select g.Key).ToList();
      return View(activeProfessors);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the idea: When the user wants to see /controller/action, then I want
i have different different pages which i want to call from one controller action
I have a controller action which passes a list of products to the view.
I have controller which gets list of keys and i want to pass them
here's the URL I want to map, http://localhost/tool/votetool/123/up routes.MapRoute( , // Route name {controller}/{action}/{toolId}/{vote},
I want to embed a link to a controller action in my page so
In my Rails controller I want to branch to a different controller's action, show
I want to have a route that looks something like: www.abc.com/companyName/Controller/Action/Id However, all the
I want to know how, from a controller action, I could identify the area
Normally my URLs look like the standard: www.example.com/controller/action Now I want to setup my

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.