I’m implementing the MVP pattern within an existing asp.net webforms application and I was wondering if there is a clean way to map my form data to a data transfer object. I’m not particularly fond of implementing it this way:
MyObject obj = new MyObject()
{
obj.Name = txtName.Text,
obj.Description = txtDescription.Text,
obj.SomeOtherValue = txtOtherValue.Text
};
Does anyone have any suggestions of a better way to tackle this problem so that I don’t have to write a mapping method for every data transfer object?
Spring.Net provides framework for bidirectional data mapping.
http://www.springframework.net/doc-latest/reference/html/web.html#web-databinding
It will be a bit complicated only for this feature. But it does provide other useful benefits as well e.g. (Dependency injection, Validation Framework, Navigation framework etc)