如何解决.NET Core 3.1-MVC-List <>值未从角度模型映射
我在.NET服务器端定义了一个模型
public class ProductRetributionData
{
public int Id { get; set; }
int product { get; set; }
int type { get; set; }
string data { get; set; }
}
public class RetributionPlan
{
...
public List<ProductRetributionData> ProductRetributionData { get; set; }
}
它是角形打字稿的对应物
export interface ProductRetributionData
{
id: number,product:number;
type: number,data: string,}
export interface RetributionPlan
{
...
productRetributionData : ProductRetributionData[]
}
当我发送POST请求
所有值均已映射,但列表内的值未
在Visual Studio中,很奇怪地映射了 Id ,但另外 3个其他值为空 出于某种原因,类型字段会获得一个额外的@
知道我在做什么错吗?
谢谢
解决方法
模型绑定器仅绑定可公开写入的属性。另外,遵守C#标准,设置属性PascalCase,默认情况下,活页夹不区分大小写。因此更改:
public class ProductRetributionData
{
public int Id { get; set; }
int product { get; set; }
int type { get; set; }
string data { get; set; }
}
收件人:
public class ProductRetributionData
{
public int Id { get; set; }
public int Product { get; set; }
public int Type { get; set; }
public string Data { get; set; }
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。