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

  • Home
  • SEARCH
  • 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 6962739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:41:57+00:00 2026-05-27T15:41:57+00:00

recently i’ve started to use viewmodels with automapper. the problem appeared immediately. for example,

  • 0

recently i’ve started to use viewmodels with automapper.
the problem appeared immediately. for example, i have such classes:

public class Zone
{
    public int ZoneId;

    public string Title;

    public int BannersCount;
}

public class ZoneView
{
    public int ZoneId
    {
        get;
        set;
    }

    public string Title;
    {
        get;
        set;
    }

    [Required(ErrorMessage = "Поле Кол-во баннеров является обязательным.")]
    [Display(Name = "Кол-во баннеров*")]
    public int BannersCount
    {
        get;
        set;
    }
}

and i don’t want to edit Title in my view. so there i show Title not in TextEditor but so:

@Model.Title

and then in my POST action ZoneView comes with empty Title:

public ActionResult Edit(ZoneView zoneView)

after this i map it to domain model:

var zone = zonesRepository.Get(zoneView.ZoneId);
Mapper.Map<ZoneView, Zone>(zoneView, zone);

and after this in zone there is empty Title. What is the best way to act in this case?

  • 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-27T15:41:58+00:00Added an answer on May 27, 2026 at 3:41 pm

    You can create a mapping definition, instructing automapper to ignore the Title property when pushing values into Zone.

    Mapper.CreateMap<ZoneView, Zone>()
       .ForMember(destination => destination.Title, member => member.Ignore());
    

    You will define this CreateMap once, at application start up. Then map as you have been.

    var zone = zonesRepository.Get(zoneView.ZoneId);
    Mapper.Map<ZoneView, Zone>(zoneView, zone);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I have been told that static class/methods are evil. Take for example my
Recently I've faced such problem. I'm working on the application, in which logging is
Recently started with ASP.NET and MVC and have a few questions on working with
Recently i am making an app on facebook. So i have use facebook api.
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I started changing some of our applications to support MS SQL Server as
Recently I found a C library that I want to use in my C++
Recently I have been dealing with windows LogonUser API. The LogonUser api returns different
recently I started using storyboard and I've the following situation: I want to set
Recently we have released our product. Our team decided to preserve the source code

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.