AttachInfo
is a field, not a property. The serializer isn't serializing fields.
public class ViewComments
{
public string Content { get; set; }
public ViewFileInfo AttachInfo { get; set; }
}
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi I have a Complex Map three layer but I am not getting the third level json
public class DetailResponse
{
List<Comments> CommentsList { get; set; }
}
public class Comments
{
public string Content { get; set; }
public FileInfo AttachInfo;
}
public class FileInfo
{
public string ID { get; set; }
public string Name { get; set; }
}
public class ViewDetailResponse
{
List<ViewComments> CommentsList { get; set; }
}
public class ViewComments
{
public string Content { get; set; }
public ViewFileInfo AttachInfo;
}
public class ViewFileInfo
{
public string ID { get; set; }
public string Name { get; set; }
}
------- mapping profile
CreateMap<DetailsResponse, ViewDetailsResponse>();
CreateMap<FileInfo, ViewFileInfo>();
CreateMap<Comments, ViewComments>()
.ForMember(dest => dest.AttachInfo, act => act.MapFrom(src => src.AttachInfo)) ;
------ controller
public IActionResult GetData(Request request)
ViewDetailsResponse data = new ViewDetailsResponse();
var detailResponse = GetDetails(request);
data = _mapper.Map<DetailsResponse, ViewDetailsResponse>{detailResponse};
return Ok(data);
I can see from the data that AttachInfo is there with the values ID and Name but the json string is not showing in swagger
AttachInfo
is a field, not a property. The serializer isn't serializing fields.
public class ViewComments
{
public string Content { get; set; }
public ViewFileInfo AttachInfo { get; set; }
}