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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:25:39+00:00 2026-06-18T06:25:39+00:00

Can someone explain to me how to use multiple models with a single view

  • 0

Can someone explain to me how to use multiple models with a single view in which each of the models represent a DB table?

What I’ve currently done is created a model file for each model.

Example Model:

[Table("Order")]
public class OrderModel
{
    [Key, Column(Order = 0)]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int OrderID { get; set; }

    [Key, Column(Order = 1)]
    public int UserID { get; set; }
    public UserProfile Account { get; set; }

    public DateTime Date { get; set; }
    public int ShipLocation { get; set; }
    public string PONumber { get; set; }

    public int StatusID { get; set; }
    public StatusModel Status { get; set; }
}

Here is the other model that encompases all the models to use in a single controller / view.

public class OrderPlacementModel
{
    public OrderModel OrderChild { get; set; }
    public OrderItemsModel OrderItemsChild { get; set; }
    public StatusModel StatusChild { get; set; }
    public MaterialsModel MaterialsChild { get; set; }
    public CategoryModel CategoryChild { get; set; }
    public PackModel PackChild { get; set; }
}
  • 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-06-18T06:25:41+00:00Added an answer on June 18, 2026 at 6:25 am
    public ActionResult PlaceOrder()
    {
      var viewModel = new OrderPlacementModel
      {
        OrderChild = new OrderModel(),//or fetch this object from your data source
        OrderItemsChild = new OrderItemsChild(),
        //...etcetera
      };
      return View(viewModel);
    }
    

    Edit

    Or, if you’ve strongly typed your view to a List<OrderPlacementModel> instead of a single instance, you could do something similar to this:

    public ActionResult PlaceOrder()
        {
          var viewModel = new List<OrderPlacementModel>();
          var model = new OrderPlacementModel
          {
            OrderChild = new OrderModel(),//or fetch this object from your data source
            OrderItemsChild = new OrderItemsChild(),
            //...etcetera
          };
          viewModel.Add(model);
          //lather, rinse, repeat for however many instances you need to send to your view.
          return View(viewModel);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone explain to me in detail when I must use each attribute: nonatomic
Can someone explain how to use JSON-RPC.net in my application for windows phone. When
Can someone explain why it's best use is for prototyping? Should it not be
Can someone explain to me why I cannot use document.getElementById('id').value inside of a function?
Can someone please explain me why would a UDP Server not need to use
Can someone explain this simple, yet deceiving, anomaly? There are two models, where B
Can someone explain how the View and ViewModel are connected? I can't find anywhere
Can someone explain why I woud use rails link_to etc instead of straight HTML
Can someone explain the use of inverse in the xml mapping file, I am
Can someone explain what the use/meaning is of the following return statement: t >

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.