Development – Leet 4 Life

Software Development Code Samples and More

Skip to: Content | Sidebar | Footer

Tag: Reflection

Convert One Entity Object to A Similar Entity Object

30 April, 2012 | C#. NET, Entity Framework | By: Michael Merrell

Not too long ago I came across the need to be able to convert one entity object to another similar entity object for use in display purposes and mapping. Even though these two objects were nearly identical they had over two hundred fields in them so writing a method to simply set properties equal to each other would have created a huge method and a higher chance of error. Using reflection I created a nice little thinned down method that will take in your source object, the output object type, and a reference to the instantiated output object. Then using [Read More…]