我正在尝试发送数据以将其保存在我的数据库中,基本,所以我将模型发送到我的控制器,然后出现此错误:
“类型“SmgApi.Models.Dto.EquipementDto”上的构造函数“Void .ctor(SmgApi.Models.Entity.EquipmentEntity)”中的每个参数都必须绑定到反序列化时的对象属性或字段。每个参数名称必须与属性或字段匹配对象上的字段。匹配可以不区分大小写。”
但我不反序列化任何东西,我不明白。我的控制器:
[HttpPost]
public async Task<IActionResult> UpdateEquipment(EquipementDto equipment)
{
return Ok(await _equipmentRepository.UpdateEquipment(new EquipmentEntity(equipment)));
}
Run Code Online (Sandbox Code Playgroud)
设备D至:
public class EquipementDto
{
[Required]
public string Id { get; set; }
public List<PropertyDto> Properties { get; set; }
[Required]
public string Type { get; set; }
public bool isInPalette { get; set; }
public EquipementDto(EquipmentEntity equipment)
{
if (equipment == null)
return;
this.Id = equipment.Id;
this.Type = equipment.Type;
this.isInPalette = equipment.IsInPalette;
this.Properties = equipment.Properties.Select(x => new PropertyDto(x)).ToList();
}
}
Run Code Online (Sandbox Code Playgroud)
我的装备界面在前面:
export interface …Run Code Online (Sandbox Code Playgroud)