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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:09:26+00:00 2026-05-14T01:09:26+00:00

I have a main Table, with several child tables. TableA and TableAChild1 and TableAChild2.

  • 0

I have a main Table, with several “child” tables. TableA and TableAChild1 and TableAChild2.

I have a view which shows the information in TableA, and then has two columns of all items in TableAChild1 and TableAChild2 respectivly, they are rendered with Partial views.

Both child tables have a bit field for VisibleToAll, and depending on user role, I’d like to either display all related rows, or related rows where VisibleToAll = true.

This code, feels like it should be in the controller, but I’m not sure how it would look, because as it stands, the controller (limmited version) looks like this:

return View("TableADetailView", repos.GetTableA(id));

Would something like this be even work, and would it be bad what if my DataContext gets submitted, would that delete all the rows that have VisibleToAll == false?

var tblA = repos.GetTableA(id);
tblA.TableAChild1 = tblA.TableAChild1.Where(tmp => tmp.VisibleToAll == true);
tblA.TableAChild2 = tblA.TableAChild2.Where(tmp => tmp.VisibleToAll == true);
return View("TableADetailView", tblA);

It would also be simple to add that logic to the RendarPartial call from the main view:

<% Html.RenderPartial("TableAChild1", Model.TableAChild1.Where(tmp => tmp.VisibleToAll == true); %>
  • 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-14T01:09:26+00:00Added an answer on May 14, 2026 at 1:09 am

    It’s a subject of great debate I think. To me there are two clear routes:

    Deferred Execution Route
    Never use ToList, always use AsQueryable in controllers. This means only the data that is necessary for presentation is retrieved and only when it is needed in the View once ToList etc. are called.

    Presentation Shows Models
    Prepare data for presentation using Model classes or results that are already filtered. Strongly type your View to the expected format.

    I prefer deferred execution myself, though in a pure MVC structure the Controller should worry about getting the information and the View should only display the Mode.

    Regardless, make sure you are using AsQueryable with your Repository.

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

Sidebar

Related Questions

I have a table which has several one to many relationships with other tables.
i have a table called category in which i have main category ids and
I have following situation. A main table and many other tables linked together with
I have a main canvas 'blackboard' in a panel, this canvas has itself several
I have a main table that I must get data from. I have a
NHibernatians! I have a table [dbo].[Wibble] and another table [dbo].[WibbleExtended]. [Wibble] is the main
I basically created some tables to play around with: I have Two main tables,
I have a database with two main tables notes and labels . They have
I have a main asp.net app, which is written in asp.net 1.1. Runnning underneath
I have a main window (#1) on my webpage from which I open a

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.