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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:20:16+00:00 2026-05-13T23:20:16+00:00

In my ASP.NET MVC app, I have a fairly complex edit page which combines

  • 0

In my ASP.NET MVC app, I have a fairly complex edit page which combines a number of models into one view.

I’m using the ViewModel pattern to combine all of this information and present one cohesive object to the View.

As an example, my ViewModel structure is something like this:

CompanyId
CompanyName
List<Employee> Employees
List<ContactMethod> ContactMethods

The Employee object has a number of basic properties, and a preferred contact method.

On the edit page, the user is given all of the employees of the company and they have the ability to add and remove (using javascript), as well as edit employee details. The ContactMethods list is used to populate the dropdown for each employee.

I’ve successfully translated my Models (read from the database) into this ViewModel and back again, so after an edit, I’m left with a ViewModel representing the current state of that company’s employees.

I’m using a Repository pattern to communicate with the database, so my question is, should I call directly into the CompanyRepository, passing the ViewModel, or should I convert the ViewModel back into Model objects first before using the Repository to write them to the database?

In short, should the Repository know about my ViewModel objects?

  • 1 1 Answer
  • 2 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-13T23:20:16+00:00Added an answer on May 13, 2026 at 11:20 pm

    I would convert the ViewModel back into Model objects first. I like keeping the dependency between my Web layer and Repository layers as loose as possible.

    I don’t think your Repository should know about your ViewModel, since that’s a web level concept.

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

Sidebar

Related Questions

Im trying to develop my first ASP.NET MVC web app and have run into
I have an ASP.NET MVC app and I want to add to each page
I have an ASP.NET MVC App, which use EF code First, for some reason
I am about to create an ASP.NET MVC app which will have over 2000
In my asp.net mvc app I have a Log object which tracks what happens
In my ASP.NET MVC 3 app I have a page where, after its form
In my asp.net mvc 2 app I have an action which is rather data-heavy.
I have an asp.net mvc app which has membership implemented. So a user has
I have an ASP.NET MVC app which depends on a lot of settings (name-value
I have an asp.net MVC app. One of the forms posts json data to

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.