C# How to use DataAnnotations StringLength and SubString to remove text

前端 未结 3 734
無奈伤痛
無奈伤痛 2021-02-19 09:10

I have a model classes that has a description property with a data annotation attribute of StringLength and length is set to 100 characters. When this property is more than 100

3条回答
  •  礼貌的吻别
    2021-02-19 09:35

    Create a view model that doesn't have a data annotation for the length, then you can map it to the entity model and truncate the value if it's longer than 100.

提交回复
热议问题