问题:构建充血模型Item类,在前端明明传入了Amount对象参数,后端却无法获取
以下是Item类中的Amount属性及构造函数
1 public Amount? Amount { get;private set; } 2 private Item() 3 { 4 5 } 6 public Item(string name) 7 { 8 this.Name = name; 9 this.Id=Guid.NewGuid(); 10 this.CreateTime=DateTime.Now; 11 }
原因:
应该在构造函数时对Amount属性进行初始化才能在控制器中接收
public Item(string name,Amount? amount,string? Des,Guid? sordId,DateTime? expDate) { this.Name = name; this.Id=Guid.NewGuid(); this.CreateTime=DateTime.Now; this.Amount = amount; this.Description = Des; this.SortId = sordId; this.ExpirationDate = expDate; }
标签:Web,类时,DateTime,Item,Amount,API,public,string,name From: https://www.cnblogs.com/budongdong/p/17135864.html