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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:07:25+00:00 2026-05-28T11:07:25+00:00

I have the following database schema : Store StoreId Name … Order OrderId StoreId

  • 0

I have the following database schema :

Store
  StoreId
  Name
  ...

Order
  OrderId
  StoreId
  ....

I have a asp.net mvc backend application with a data repostory like this (simplified):

   public IQueryable<Order> GetOrders() {

        return storeDB.Orders
            .OrderByDescending(o => o.DateDue)
            .ThenByDescending(o => o.DateCreated);
    }

I have similar code to show sales, employees, products etc … I want to put a dropdown somewhere in the application to allow me to set a global filter to show only orders, employees, products, etc … from a given StoreId, if storeId is null I should show all records from all stores (remove the filter) what is the best way to do it ?

Should I set the storeId in the session and filter the data in the controller? should I add a storeId parameter in my datalayer and evalute if it’s null or not before applying the filter?

  • 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-28T11:07:25+00:00Added an answer on May 28, 2026 at 11:07 am

    I would go for a List<Int> or List<Guid> or whatever DataType you use for the StoreID and use this list as a parameter in the method. Then you can eventually also show orders for multiple stores, or for a single store or for all stores. And then simply use an if statement to detect of the list contains something or nothing, something like:

    public IQueryable<Order> GetOrders(List<Guid> storeIDs)
    {
      if(storeIDs == null || storeIDs.Count == 0)
      {
        return storeDB.Orders
               .OrderByDescending(o => o.DateDue)
               .ThenByDescending(o => o.DateCreated);
      }
      else
      {
        return storeDB.Orders
               .Where(o => storeIDs.Contains(o.StoreID))
               .OrderByDescending(o => o.DateDue)
               .ThenByDescending(o => o.DateCreated);
      }
    } 
    

    This is a nice setup according to me. Don’t store the filter parameters in a Session or whatever. In the way described above the method can be used from / by multiple functional “places” in your application.

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

Sidebar

Related Questions

I have a database where I store objects. I have the following (simplified) schema
I have a MySQL database called People which contains the following schema <id,name,foodchoice1,foodchoice2> .
I have an application built upon ASP.NET 3.5 and PostgreSQL 8.3. My database has
I have no control over database schema and have the following (simplified) table structure:
I have a database schema that is similar to the following: | User |
I have the following database schema: http://lh4.ggpht.com/_SDci0Pf3tzU/SdM3XnAmmxI/AAAAAAAAEps/Ie3xW3ZVNfQ/s400/styleerror.png And this is my mapping file: <?xml
I have an ASP.NET MVC 3 app that is using SQL Server CE 4.0
We have a multi module project with following modules: Database Persistence Business Application The
I have the following database schema: table courses: id tutor_id title table course_categories: id
I have to store the following information into a database, to be used by

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.