I have Dto like this:
public class OptimizationNodeDto : IModelWithId
{
public int Id { get; set; }
[DataMember(Name = "parentId")]
public int? ParentOptimizationNodeId { get; set; }
[DataMember(Name = "name")]
public string Text { get; set; }
[DataMember(Name = "opened")]
public bool IsOpened { get; set; }
[DataMember(Name = "selected")]
public SelectedStates SelectedState { get; set; }
public List<OptimizationNodeDto> Children { get; set; }
}
I want that when I send this object with any API it should give property name in JSON as like mentioned in DataMember but it's not happening. For ex.ParentOptimizationNodeId should be as parentId in JSON result. Here I am sending the Dto:
[Route("{roleId}/Optimizations")]
[HttpPost]
public IHttpActionResult GetOptimizationList([FromUri]int roleId, [FromBody] FilterDto filter)
{
try
{
var groupManBo = _serviceLocator.Resolve<IRoleManagerBo>();
return Ok(groupManBo.GetOptimization(roleId, this.ViewboxUser, filter));
}
catch (Exception ex)
{
return this.HandleError(ex);
}
}