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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:41:23+00:00 2026-05-28T05:41:23+00:00

I have a view for editing a specific project. Here is what I do

  • 0

I have a view for editing a specific project. Here is what I do for preparing a view model for this view:

  1. Retrieve project info
  2. Prepare a new view model object anp map my project into it.
  3. Prepare a TechnologyString by calling a function to fill it.
  4. Showing the view.

    public ActionResult Edit(string slug)
    {
        // 1
        Project project = m_ProjectBusiness.GetProject(slug);
    
        // 2
        ProjectEditViewModel viewModel = new ProjectEditViewModel
        {
            ProjectToEdit = Mapper.Map<Project, ProjectFullViewModel>(project)                 
        };
    
        // 3
        viewModel.ProjectToEdit.TechnologyString = m_ProjectBusiness.ListTechnologies(project);
    
        // 4
        return View(viewModel);
    }
    

As you can see for point 3, I fill in a string (TechnologyString) located in my view model, under my object ProjectToEdit. I would like to know if it is possible to do this operation directly (and automatically) when the mapping occurs?

Thanks.


EDIT

I found a solution based on mapping. Here it is:

        Mapper.CreateMap<Project, ProjectFullViewModel>()
             .ForMember(dest => dest.TechnologyString,
                        opt => opt.MapFrom(src => String.Join(" ", src.Technologies.Select(x => x.Name))));

So, I retrieve every technologies attached to my project and create a string with all items separated by a space.

Readers: Please note that Darin’s solution below works in case of Technologies are not part of my domain model. But in this case it is.

  • 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-28T05:41:23+00:00Added an answer on May 28, 2026 at 5:41 am

    This is not something that should be handled at your mapping level. You could use a service layer in which you will define an aggregate root for the project and the technology:

    public class ProjectAggregateRoot
    {
        public Project Project { get; set; }
        public string TechnologyString { get; set; }
    }
    

    and then have a method in your service layer that will return this aggregate root:

    public ProjectAggregateRoot GetProjectBySlug(string slug)
    {
        var project = _repo.GetProject(slug);
        var technoString = _repo.ListTechnologies(project);
        return new ProjectAggregateRoot
        {
            Project = project,
            TechnologyString = technoString
        }
    }
    

    and then you could directly map between the aggregate root that will be returned by your service layer and the view model, like so:

    public ActionResult Edit(string slug)
    {
        var model = _service.GetProjectBySlug(slug);
    
        // now you have everything in the aggregate root to build your view model
        var viewModel = Mapper.Map<ProjectAggregateRoot, ProjectEditViewModel>(model);
        return View(viewModel);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC view for editing a model object. The edit page
I have a view especially designed for editing general project infos (name, description, ...).
I have a view user control that can post form. This control can be
I am editing and have already saved a Vendor.ascx partial view in VS 2010.
I have a View that handles the Edit action for editing a weekly update
I suspect this is simple and I'm just missing it. I have a view
I have photo editing view that displays an OpenGL ES 2.0 view. I want
I have a TabContainer inside a Multiview. When I bring up a specific editing
I'm editing multiple instances of a parent model in an index view in one
I have a view which contains a tableview, (i call this view the EquationView,

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.