MVC mapping viewmodels to POCOs
I am developing an ASP.NET MVC 3 application using EF 4 and POCOs. One of the main challenges that I have is how to map a ViewModel to a POCO.
For example:
I have two POCO object -> User and Order. Furthemore I have a ViewModel --> UserOrderModel containing both models. Whenever some data is posted I would like to map the UserOrderModel to a User and an Order object. It is pretty straightforward to do this (perhaps just map on request in the controller) but I am wondering if there is a nice, clean solution for that problem (I was initially thinking of creating a generic mapping interace for all view models so that they must define how to map themselves to a POCO object)
Thanks in开发者_如何学C advance
Sounds like a job for AutoMapper
Great example here on mapping MVC ViewModel's to POCO's.
精彩评论