Auto Mapper (edit)
Integrate with ASP.NET MVC 5.2.3
Auto Mapper Version: 6.2.2.0
https://www.codeproject.com/Articles/61629/AutoMapper
https://www.c-sharpcorner.com/blogs/using-automapper-in-c-sharp
https://www.c-sharpcorner.com/article/getting-started-with-automapper/
Global.asax.cs
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AutoMapperConfiguration.Initialize();
}
}
AutoMapperConfiguration.cs
public class AutoMapperConfiguration { public static void Initialize() { Mapper.Initialize(cfg => { cfg.CreateMap<User, Account>() // User -> Account .ReverseMap(); // Account -> User }); } }
Using the Code
Account objAccount = Mapper.Map<Account, User>(objAccount);
Account.cs
public class User { public int Id { get; set; } public string UserName { get; set; } }
User.cs
public class User { public int Id { get; set; } public string UserName { get; set; }
public string Password { get; set; } }