Merge Two Entities, but Ignore fields and keep original value

May 19, 2011 at 9:40 PM


I have a model and a viewmodel.

I want to retain the the Id of the model along with some other variables (Auditing properties).

public class Person {

    public int Id {get;set;}

    public string CreatedBy {get;set;}


public class PersonViewModel {

    public int Id {get;set;}

    public string CreatedBy {get;set;} // go away


when I do an model.InjectFrom(viewmodel) I'd like the CreatedBy to be retained on the model, since I do not post back the CreatedBy in the form.

Any help would be appreciated.


May 19, 2011 at 10:48 PM

basically you want to ignore the CreatedBy


inherit the ConventionInjection and specify your own algorithm for matching

and there you can specify that if targetPropName = "CreatedBy" then return false;