【发布时间】:2021-03-19 22:54:56
【问题描述】:
这是要验证的属性。 (来自我的 cshtml.cs(Razor)的代码)
[BindProperty]
public TMedProductStorageLocation TMedProductStorageLocation { get; set; }
[BindProperty]
public IList<TStorageLocation> TStorageLocations { get; set; }
[BindProperty]
public int SelectedStorageLocationId { get; set; }
[BindProperty]
public TMedProduct SelectedProduct { get; set; }
[BindProperty]
public int RelocateAmount { get; set; }
这些是我要验证的属性。但它也验证了:
public class TSubstanceGroup
{
public TSubstanceGroup()
{
TMedProducts = new HashSet<TMedProduct>();
}
[Key]
public int Id { get; set; }
[Required(ErrorMessage = "Geben Sie eine Bezeichnung ein.")]
public string Name { get; set; }
public ICollection<TMedProduct> TMedProducts { get; set; }
}
因为这是与 TMedProduct 相关的表。 如何避免对相关表进行验证?
【问题讨论】:
-
您能分享一下您的剃须刀页面前端吗?
标签: validation asp.net-core entity-framework-core razor-pages entities