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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:09:07+00:00 2026-06-17T13:09:07+00:00

I have a base MappedViewModel , that is, it is built for ‘automatic’ mapping

  • 0

I have a base MappedViewModel, that is, it is built for ‘automatic’ mapping to and from domain and other models:

public abstract class MappedViewModel<TEntity> : ViewModel
{
    public virtual void MapFromEntity(TEntity entity, bool forCreate = false)
    {
        Mapper.Map(entity, this, typeof(TEntity), GetType());
        if (ModelPurpose == ViewModelPurpose.Create)
        {
            NullifyReferenceProperties();
        }
    }

    public virtual TEntity MapToEntity()
    {
        return Mapper.Map<TEntity>(this);
    }

    protected virtual void NullifyReferenceProperties()
    {            
    }
}

I somehow feel that NullifyReferenceProperties should be abstract in the base class, to force classes that need it to implement it, but many classes don’t need it, and many that need it when the model is not built for creating a new entity. Is it OK like it is now as virtual, or is there some way I can determine how to enforce its use?

Maybe a base MappedViewModel with a derived MappedViewModelForCreate?

  • 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-17T13:09:08+00:00Added an answer on June 17, 2026 at 1:09 pm

    If you want to force ALL classes derived from MappedViewModel to override the NullifyReferenceProperties method make it abstract. If not, I think it’s better to just leave it virtual.

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

Sidebar

Related Questions

I have a base class that looks like this: public abstract class MyBaseClass {
I have a base class ActivityA that has some dialogs: public static final int
I have base classes like this: public class Scene { public IList<SceneModel> Models {get;
I have a base class, like this for my POCO objects public abstract class
I have a base class that contains the following events: public event EventHandler Loading;
I have a base class that has an abstract getType() method. I want subclasses
In the project I'm working on now, we have base Entity class that looks
I have a base class: class motorcycle { public: virtual int speed() { return
I have a base class ( car ) and a class that inherit the
I have a base and a derived exceptions, public inner classes of store: //base

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.