diff --git a/xml/System.ComponentModel.DataAnnotations/StringLengthAttribute.xml b/xml/System.ComponentModel.DataAnnotations/StringLengthAttribute.xml index 002bd74d7a7..3e78b6a25c1 100644 --- a/xml/System.ComponentModel.DataAnnotations/StringLengthAttribute.xml +++ b/xml/System.ComponentModel.DataAnnotations/StringLengthAttribute.xml @@ -38,9 +38,11 @@ and properties identify the largest number of bytes that are required in order to store a string. - - + ASP.NET Dynamic Data enables CRUD (Create, Read, Update and Delete) operations in a data model. You can specify the minimum and maximum length of characters for each field when data is being inserted or updated. For character data types, the and properties identify the largest number of bytes that are required in order to store a string. + +You can use [composite formatting](~/docs/standard/base-types/composite-formatting.md) placeholders in the error message: +{0} is the name of the property; {1} is the maximum length; and {2} is the minimum length. +The placeholders correspond to arguments that are passed to the method at runtime. ## Examples The following example shows how to limit the number of characters in a field. This example works with the ThumbnailPhotoFileName field in the Products table in the AdventureWorksLT database. The field is limited 4 characters by applying the attribute to the partial class that represents the Product entity. @@ -59,6 +61,10 @@ public class ProductMetadata [StringLength(4, ErrorMessage = "The ThumbnailPhotoFileName value cannot exceed 4 characters. ")] public object ThumbnailPhotoFileName; + [ScaffoldColumn(true)] + [StringLength(4, ErrorMessage = "The {0} value cannot exceed {1} characters. ")] + public object PhotoFileName; + } ``` @@ -74,6 +80,10 @@ Public Class ProductMetadata _ Public ThumbnailPhotoFileName As Object + _ + _ + Public PhotoFileName As Object + End Class ``` @@ -267,4 +277,4 @@ End Class - \ No newline at end of file +