【发布时间】:2023-01-20 14:43:29
【问题描述】:
我有一个实体,其中几乎没有字符串属性。我在我的模型类中为他们设置了MaxLength。现在我想获得每个字段的最大长度。我怎样才能实现它?
public class Customer
{
[Key]
public int CustId { get; set; }
[MaxLength(100)]
public string Cust { get; set; }
[MaxLength(100)]
public string Street { get; set; }
[MaxLength(20)]
public string PostalCode { get; set; }
[MaxLength(100)]
public string City { get; set; }
[MaxLength(2)]
public string Country { get; set; }
}
【问题讨论】:
-
目前尚不清楚您希望如何获得最大长度。你能详细说明或举个例子吗?
-
您可以通过多种方式访问信息,但这取决于您希望在何时何地访问它。
标签: c# .net-core entity-framework-core