I need to convert between the two classes and want to support DRY but not break the single responsibility pattern ...
public class Person
{
public string Name {get;set;}
public int ID {get;set;}
}
public class PersonEntity : TableServiceEntity
{
public string Name {get;set;}
public int ID {get;set;}
}
Additional Information
I have some Model objects in my ASP.NET MVC application. Since I work with Azure storage, I see the need to often convert to a ViewModel and from a ViewModel and AzureTableEntity.
I usually did this left-right assignment of variables in my controller.
Q1
Besides the implicit / explicit conversion, should this code reside in a controller (x)or datacontext (y)?
Person <--> View <--> Controller.ConverPersonHere(x?) <--> StorageContext.ConvertPersonHere(y?) <--> AzurePersonTableEntity
Q2
Should I do an implicit or explicit conversion?
Q3
Which object should contain the conversion code?
Update
WCF , . . .