We are currently using AutoMapper 5.1.1 and using Explicit Expansion feature. I have a class as a Loan which has property as LoanTypeId-> int and other Property which is of type called Property. In certain cases we want to fetch everything in the property which is street & city and certain cases we want to fetch only street. Is that something Possible. Because If i understand we have to pass "Property" something like this which would fetch everything from Property.
_loanRepository.Value.GetById(request.EntityId)
.ProjectTo<DataAttributeResponse>(mapperConfiguration, null, new[] { "LoanTypeId", "Property" })
CreateMap<Model.Property, Property>()
.ForMember(d => d.Street, src => src.MapFrom(l => l.Street))
.ForMember(d => d.City, src => src.MapFrom(l => l.City));
CreateMap<Model.Loan, DataAttributeResponse>()
.ForMember(d => d.LoanTypeId, src => src.MapFrom(l => l.LoanTypeID))
.ForMember(d => d.Property, src => src.MapFrom(l => l.Property))
.ForAllMembers(opt => opt.ExplicitExpansion());