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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:54:50+00:00 2026-05-20T20:54:50+00:00

For my management application, i have in my modelfolder a dbml file with entities

  • 0

For my management application, i have in my modelfolder a dbml file with entities (ex. person, company, address, contact, …)

With help of mvc i can handle all CRUD operations so far, but only from 1 entity.
Now I want to show in 1 view information of the person entity and also the corresponding information of contact and address entity. The entities are already connected with the correct relations.

How can I do this efficiently ?

  • 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-20T20:54:51+00:00Added an answer on May 20, 2026 at 8:54 pm

    You need to create a ViewModel that will be used to hold information from each entity you need within your actual View.

    For example, I have a controller called PublicationsController that will build a catalog page within my web application. One ActionResult needs to provide a ViewModel called PublicationsListViewModel to my View.

    PublicationsListViewModel:

    public class PublicationsListViewModel
    {
        public IList<Publication> Publications { get; set; }
    
        public PagingInfo PagingInfo { get; set; }
    
        public String CurrentCategory { get; set; }
    
        public Dictionary<String, String> SelectedItems { get; set; }
    }
    

    As you can see, the PublicationsListViewModel is just a container for each Entity that needs to be passed to my View.

    My PublicationsController looks like this:

    Controller:

    public ActionResult List(Cart cart, string category, int page = 1)
    {
        Dictionary<String, String> selectedItems = new Dictionary<String, String>();
    
        foreach (var line in cart.Lines)
        {
            selectedItems.Add(line.Publication.PDFID.ToString(), line.Quantity.ToString());
        }
    
        foreach (var line in cart.Lines)
        {
            ViewData.Add(line.Publication.PDFID.ToString(), line.Quantity.ToString());
        }
    
        var publicationsToShow = (category == null)
                        ? publicationsRepository.Publications
                        : publicationsRepository.Publications.Where(x => x.Category.Equals(category, StringComparison.CurrentCultureIgnoreCase));
    
        var viewModel = new PublicationsListViewModel
        {
            Publications = publicationsToShow.Skip((page - 1) * PageSize).Take(PageSize).ToList(),
            PagingInfo = new PagingInfo
            {
                CurrentPage = page,
                ItemsPerPage = PageSize,
                TotalItems = publicationsToShow.Count()
            },
            CurrentCategory = category,
            SelectedItems = selectedItems
        };
    
        return View(viewModel); // Passed to view as ViewData.Model (or simply Model)
    }
    

    And my View looks like this

    View:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<myNameSpace.WebUI.Models.PublicationsListViewModel>" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
        Publications : <%: Model.CurrentCategory ?? "All Publications" %>
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <% 
        foreach (var publication in Model.Publications)
        { 
           Html.RenderPartial("PublicationSummary", publication, ViewData); 
        } 
        %>
        <div class="pager">
            <%: Html.PageLinks(Model.PagingInfo, x => Url.Action("List", new { page = x, category = Model.CurrentCategory }))%>
        </div>
    </asp:Content>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have contact management / CRM application used in-house by our company, It is
My company has a web document management application and I have been assigned to
Let's say that I have written a custom e-mail management application for the company
I have property management application consisting of tables: tenants landlords units properties vendors-contacts Basically
We have a job management application running (Access) with the database in SQL Server
We have a Server/Client cybercafe management application which used to work fine on Windows
I have content management system application that uses a polymorphic tree table as the
We have an application (a custom network management tool for building automation) that supports
I have a Django 1.3 application. I have several management commands. I want each
I have a question on javascript window management. My application opens an iframe which

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.