I have an ASP.net MVC project, in which i am binding a viewmodel with multiple classes, some of these classes are mandatory, some of them are optional as they can be used for certain type of view.
public class BaseModel
{
public bool IsCompleted { get; set; }
public int StepCount { get; set; }
public EstModel EstUploads { get; set; } // mandatory property
public DocModel DocUploads { get; set; } // mandatory property
public InitSumModel initSum { get; set; } // mandatory property
public OptionalModel optional { get; set; } // optional property
}
Now, I don't want the optional class to be included if certain conditions are not satisfied. Some one recommended me to use interface and inheritence but i am not familiar with the implementation.
Please recommend any implementation guide as i am newbie at MVC.