I have following layers in my solution:
- App.Domain
- App.Service
- App.Core (maybe you call this one App.DataLayer)
- App.Web
Software design pattern is not my question, I have following Model in Domain
public class Foo {
public int Id {get;set;}
public int Name {get;set;}
public int Value {get;set;}
}
I want to use this model on the view (for example home page) AND I want to use Id, Name & Value
, so if I want to create ViewModel, I'll add following:
public class FooViewModel {
public int Id {get;set;}
public int Name {get;set;}
public int Value {get;set;}
}
So, is that good idea? or just use Foo
instead of FooViewModel
?
Model
usually passed to theView
? Why exactly do you need to recreate the fields of theModel
in theView
? If separation of concerns is a goal ofMVC
, under what circumstances would one want to do the same thing withModel
andView
? IfViewModel
is both, why not by extending / composing bothModel
andView
?