Add option to dynamically exclude fields during map method invoke
Closed this issue · 1 comments
Use-Case
There might be instances during mapping to view model that you want to ignore a property that contains a large list. This is not supported in the current version and the workaround for this is to remove the MappedTo
attribute of the property, but this will cause the property to never be mapped to another model. This might lead to a more complex model design which is not the goal of the project.
Proposed Solution
Additional parameter in
Model model = new Model();
using ModelVM modelVM = model.MapTo<ModelVM>(/*here*/);
to accept list of ignored target properties.
Use-Case
There might be instances during mapping to view model that you want to ignore a property that contains a large list. This is not supported in the current version and the workaround for this is to remove the
MappedTo
attribute of the property, but this will cause the property to never be mapped to another model. This might lead to a more complex model design which is not the goal of the project.
Proposed Solution
Additional parameter inModel model = new Model(); using ModelVM modelVM = model.MapTo<ModelVM>(/*here*/);
to accept list of ignored target properties.
New proposed solution:
Additional Property Attribute
public class SampleObject
{
[IgnoreIf(typeof(AnotherObject))]
[MappedTo("FNAME")]
public string FirstName { get; set; }
}
Refactor the mapper method to check for the IgnoreIf
attribute