c# - ViewModel that use BaseViewModel and inherit of Model -


i have n-layer app (entity layer - business layer - web layer). use viewmodels (in web layer) have list of dropdown, etc erich basic business object (entity layer) ui. that, use baseviewmodel (web layer) in every viewmodel has dropdown or default values, allows me call methods fill datas, usefull.

now want find smart way avoid re-type entity layer properties vm.

for moment, here example of do:

model :

class customobjectmodel {  public int id {get;set;}  public string name {get;set;}  public string description {get;set;}  } 

vm :

public class customobjectviewmodel : baseviewmodel {  public int id {get;set;}  public string name {get;set;}  public string description {get;set;}  public list<possiblenames> string  {get;set;}  } 

basevm:

public class baseviewmodel{ public list<string> fillnames(){...} public list<string> defaultname(){...} } 

and don't want re-type model properties vm... how?

i use inheritance: customobjectmodel inherits of baseviewmodel , customobjectviewmodel inherits of customobjectmodel not clean have reference of web entites project , makes me feel uncomfortable it.

thanks me :-)

you can use automapper http://automapper.org/ or similar expressionmapper http://www.codeproject.com/tips/1009198/expressmapper-the-new-net-mapper


Comments