.NET Core 3.1 - MVC - 未从 angular 模型映射的列表 <> 值
.NET Core 3.1 - MVC - List<> values not mapped from angular model
我在 .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; }
}
它是 angular 对应的打字稿
export interface ProductRetributionData
{
id: number,
product:number;
type: number,
data: string,
}
export interface RetributionPlan
{
...
productRetributionData : ProductRetributionData[]
}
当我发送 POST 请求时
所有值都已映射,但列表中的值未映射
在visual studio中,奇怪的是Id被映射了,但是3其他值是空的
并且类型字段由于某种原因得到一个额外的@
知道我做错了什么吗?
谢谢
模型绑定器仅绑定 publicly-writable 属性。此外,遵守 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; }
}
我在 .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; }
}
它是 angular 对应的打字稿
export interface ProductRetributionData
{
id: number,
product:number;
type: number,
data: string,
}
export interface RetributionPlan
{
...
productRetributionData : ProductRetributionData[]
}
当我发送 POST 请求时
所有值都已映射,但列表中的值未映射
在visual studio中,奇怪的是Id被映射了,但是3其他值是空的 并且类型字段由于某种原因得到一个额外的@
知道我做错了什么吗?
谢谢
模型绑定器仅绑定 publicly-writable 属性。此外,遵守 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; }
}