【发布时间】:2023-01-12 11:10:36
【问题描述】:
当我使用 TryUpdateModelAsync 方法更新模型时出现此错误,任何人都对此有想法
传递的表达式节点类型“NewArrayInit”的表达式无效。仅支持模型属性的简单成员访问表达式。
这个问题的代码如下。
[HttpPost,ActionName("Edit")] [ValidateAntiForgeryToken] public async Task<ActionResult> EditLocaton([ModelBinder(typeof(EncryptDataBinder))]int id, IFormCollection formCollection) { ModelState.Clear(); LocationModel location = new LocationModel(); try { await TryUpdateModelAsync<LocationModel>(location, "", p => new object[] { p.ID, p.Name, p.Code, p.RowVersion });位置模型的代码
public class LocationModel : BaseEntity { [Required] [StringLength(100)] [Display(Name = "Location Name")] public string Name { get; set; } [Required] [StringLength(20)] public string Code { get; set; } [NotMapped] public string enID { get; set; } }请帮助解决这个问题。
【问题讨论】:
标签: asp.net-core-mvc