将复杂的模型 angularjs 发布到 web api



假设我有这个模型

public class HouseHolds
{
    public string Code { get; set; } 
    public List<HouseHoldBeneficiaries> HouseHoldBeneficiaries { get; set; }
}
public class HouseHoldBeneficiaries
{
    public Guid HouseHoldId { get; set; }
    public Guid BeneficiaryId { get; set; }
    public int HouseHoldRelationShipId { get; set; }
}

我想将新的 HouseHold 发布到数据库,所以我从 angularjs 发送结果但我无法绑定家庭受益人列表。

对象

Code: "wer"
HouseHoldBeneficiaries:
HouseHoldRelationShipId: 2
BeneficiaryId: EAFC7940-5FAD-4C04-BC01-6D052BA5E711

但是我的家庭受益人在模型中总是为空??

您的HouseHoldBeneficiaries是一个集合,因此需要像 json 数组一样发送

{
Code:"wer",
HouseHoldBeneficiaries: [
{
 HouseHoldRelationShipId: 2,
 BeneficiaryId: EAFC7940-5FAD-4C04-BC01-6D052BA5E711
}
]
}

最新更新