AutoMapper mapping properties with private setters
问题 Is it possible to assign properties with private setters using AutoMapper? 回答1: If you set the value for this properties in the constructor like this public class RestrictedName { public RestrictedName(string name) { Name = name; } public string Name { get; private set; } } public class OpenName { public string Name { get; set; } } then you can use ConstructUsing like this Mapper.CreateMap<OpenName, RestrictedName>() .ConstructUsing(s => new RestrictedName(s.Name)); which works with this code