I have a class with ~400 string properties(it's auto-generated) I would like to apply [StringLength(50)] to all properties within the class. Is that is possible without copy-pasting the attribute 400 times?
How to apply at once StringLength attribute to all properties within the class?
168 views Asked by Yoda At
1
There are 1 answers
Related Questions in C#
- Add additional fields to Linq group by
- couldn't copy pdb file to another directory while consuming wcf web service
- Why are the aliases for string and object in lowercase?
- WPF MessageBox Cancel checkbox check
- Resolve object using DI container with object instance
- Creating a parametrized field name for a SELECT clause
- Does compiler optimize operation on const variable and literal const number?
- Get data from one form to another form in C#
- Writing/Overwriting to specific XML file from ASP.NET code behind
- Deleting Orphans with Fluent NHibernate
Related Questions in .NET-CORE
- NLog with DNX Core 5.0
- How should I reference HttpClient for dnx451 and dnxcore50?
- DNX Core 5.0 library to target any platform. No System.Random class. Workarounds or options?
- Kestrel Running which framework?
- Directory.CreateDirectory not exists in .NET Core
- asp.net dnxcore50 load assembly by file path
- .NET Core doesn't depend on any installation?
- Why is linq to object implementing iterators manually?
- Microsoft Band and WPF
- Determine port in asp.net core
Related Questions in DATA-ANNOTATIONS
- Custom ValidationAttribute doesn't work. Always returns true
- manual mvc4 data annotation model validation
- VS2013 MVC - Display name not working on some fields
- DataAnnotations for jquery validation - Display error from one field on another field
- Do Data Annotations only work with ASP.NET?
- ValidationResults on TryValidateObject is null
- Entity Framework Code First from database not adding Key attribute
- EF6 Self Referencing Table with multiple parent properties, single child collection
- The specified value does not conform to the required format yyyy-MM-dd
- Use DataTypeAttribute with DataType.EmailAddress without validation
Related Questions in ASP.NET-CORE-7.0
- Equivalent for NotFoundObjectResult in .NET 7 isolated worker model Azure Functions
- Updating many-to-many relationship using Entity Framework Core
- Mapping list of an object in ASP.NET Core 7 Web API from multipart/form-data request
- How to utilize multiple parameters in a httpclient request in ASP.NET Core 7
- HttpContextAccessor.HttpContext.User has sometimes null fields (but itself User is not a null)
- How to loop through pagination for a shopify api request in ASP.NET Core 7 with HttpClient
- The specified solution configuration is invalid
- Using ASP.NET Core background service without overlapping execution
- Do i need to implement Controller Logic to grab my ApplicationUser by ID when submitting a form in ASP.NET Core 7?
- Bind flags enum in Razor Pages handler
Related Questions in C#-11.0
- Some C# 11&12 Practicing failed
- C# 11 / .NET 7 - nullability behavior after "is" check for Nullable<value type>
- `required` property and EF Core
- Why do I get "CS8618: Non-nullable property must contain a non-null value when exiting constructor" on a string property?
- How to use a switch expression to match a value where it equals another non-constant value
- Passing a reference to a value in a struct in C# 11
- C# 11 escape rules for ref parameters: ref int vs Span<int>
- How to apply at once StringLength attribute to all properties within the class?
- Creating a "ref tuple"
- ModelState.IsValid is false when I have a nullable parameter and send it as null
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
There is a way to do it using reflection, but this approach will apply the attributes at runtime, not at compile time.
Then you can call
AddStringLengthAttribute(typeof(YourClass), 50);