You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, code generation will ignore properties that annotated [AdaptIgnore] attribute. But you can add more settings which include IgnoreAttributes, IgnoreNoAttributes, IgnoreNamespaces.
Example:
config.AdaptTo("[name]Dto").ForType<Student>().IgnoreNoAttributes(typeof(DataMemberAttribute));publicclassStudent{[DataMember]publicstringName{get;set;}//this property will be generatedpublicstringLastName{get;set;}//this will not be generated}
By default, code generation will forward type on the same declaration. (For example, Student has ICollection<Enrollment>, after code generation StudentDto will has ICollection<EnrollmentDto>).
You can override this by AlterType.
config.AdaptTo("[name]Dto").ForAllTypesInNamespace(Assembly.GetExecutingAssembly(),"Sample.CodeGen.Domains").AlterType<Student,Person>();//forward all Student to Person
Generate readonly properties
For AdaptTo and AdaptTwoWays, you can generate readonly properties with MapToConstructor setting.