Click here to Skip to main content
15,889,526 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
What I'm trying is to create mapper method.
public static T ConvertObjects<T>(T serviceObject)

I call in following way:
CollectionGroupEntity serviceObject = new CollectionGroupEntity();
var result = CollectionGroupMapper.ConvertObjects<CollectionGroupViewModel>(serviceObject);


Problem is serviceObject parameter is also taking CollectionGroupViewModel type, but I want it to send in CollectionGroupEntity type.

Is there any way where I can control the serviceObject like
public static T ConvertObjects<T>(T1 serviceObject)


Thanks in advance
Posted
Comments
Tomas Takac 11-Nov-14 3:23am    
Just to make sure: you are trying to convert CollectionGroupEntity to CollectionGroupViewModel? Is there any relation between those two?
dhage.prashant01 11-Nov-14 4:36am    
Yes, CollectionGroupEntity is service entity while CollectionGroupViewModel is MVC model.

In short, I want to create single mapper function which can map objects in both way.
Tomas Takac 11-Nov-14 5:25am    
You didn't answer the part about relation between the two classes. My guess is you want to do something like this: public static ViewModel<T> ConvertObjects<T>(Entity<T> entity) where T: MyDto. Can you post a simplyfied version of your entity and view model classes?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900