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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:27:44+00:00 2026-05-20T06:27:44+00:00

I read a few articles and I’ve seen the video from MvcConf 1 in

  • 0

I read a few articles and I’ve seen the video from MvcConf 1 in which Jimmy Bogard demonstrates the usage of AutoMapper but I’m still confused.

I have a User POCO class which has a bunch of properties. I also have a RegisterViewModel class which contains a sub-set of the User class’ properties. Now when a user is registering, she’ll be filling the data into the empty RegisterViewModel instance passed to the view. Then this data has to be mapped to the User instance to be added to the database, but there are certain properties on the User which need to be entered as defaults (something like RegistrationDate which should be assigned to DateTime.Now). What would I do in this case?

Moreover, let’s say I’m updating a User instance. First I need to get the data from the database and map it to the UpdateUserViewModel class. Then when the user submits the changes, those have to be mapped back to the User instance. In this case, do I need to do two separate Mapper.CreateMap<>() entries in my configuration file or does AutoMapper do that automatically for me?

I guess that’s it for now, your help will be highly appreciated! 🙂

  • 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-20T06:27:45+00:00Added an answer on May 20, 2026 at 6:27 am

    For the first scenario you could define those missing properties in your mapping:

    Mapper
        .CreateMap<RegisterViewModel, User>()
        .ForMember(
            dest => dest.RegistrationDate,
            opt => opt.UseValue(DateTime.Now)
        );
    

    For the second scenario you need two separate mappings because AutoMapper doesn’t automatically define bi-directional mappings:

    Mapper.CreateMap<UpdateUserViewModel, User>();
    Mapper.CreateMap<User, UpdateUserViewModel>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read a few articles talking about checkboxes always returning a false state, but
I've read up a good few articles etc., here and from Google, about trying
I have read few good articles about NHibernate localization but nothing seems to fit
I've tried to read up on a few articles about this, but some of
I've read a few articles about cryptography in .net, which leads me to the
I've read a few articles about MVC but there's one thing that isn't clear
I read few articles on float used with nested divs but I'm unsure as
I'm just starting to play around with directx and I've read a few articles
Having read up on quite a few articles on Artificial Life (A subject I
I've read the article (and few others on the subject), but still can't figure

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.