i have implemented table-per-hierarchy pattern into one of my entities and it looks like this:
atm, sube and acikhava entities are basically derived from mekan entity. there is no problem with these. well, what i want to know is, how should i implement this into CRUD views.
all of these entities have their own viewmodels, and mekan itself is not meant to be created by itself, the user can only create an atm, sube or acikhava, because mekan is an abstract entity. but i can't just set the model of view as the base entity and go on, because it isnt meant to be used that way, and throws errors.
now, should i behave this derived entities as completely different entities, and create separate views of them for every different action ? or find another way to achieve this.
thanks.
You could create a view model for Mekan:
public class MekanViewModel {
public AtmViewModel Atm {get;set;} // you said you already created these view models
public SubeViewModel Sube {get;set;}
public AcikhavaViewModel Acikhava {get;set;}
}
Your view would be strongly typed:
@model MekanViewModel
@Html.TextBoxFor(m=>m.Atm.Atm_TerminalNo)
etc
You're controller that would receive the data would receive MekanViewModel
[HttpPost]
public ActionResult Create(MekanViewModel mekan)