How to ignore public static property with AutoMapper using the Fluent approach?

Skip to first unread message

Michael Lenart

May 11, 2021, 9:36:13 PM5/11/21
to AutoMapper-users

I have a scenario that I have a source class (call it Foo) that has a public static property:

public class FooStatus 

              public static readonly FooStatus Applied = new FooStatus(1, "Applied"); 

              public static readonly FooStatus Applied = new FooStatus(2, "Open"); 

               public static readonly JobApplicationStatus[] AllStatuses = { Applied, Closed };

                public int Id { get; } 

                public string StatusDescription { get; } 


When mapping this class to a DTO object I want to exclude these static properties. How would you do it using the Fluent approach with AutoMapper? If you cant with the Fluent approach, how would you do it with the Attribute Matching approach?

I am using AutoMapper.Collection nuget v.7.0.1 and AutoMapper.Extensions.Microsoft.DependencyInjection nuget 8.1.1

Reply all
Reply to author
0 new messages