Is your feature request related to a problem? Please describe.
Validating collections of objects whose aggregate values must be a certain value are difficult to validation without a custom validator. Instead, it would be useful to have a validation attribute that can be applied to a member that abstracts away the source of the aggregate value.
The idea can be exemplified with the following code:
publicIEnumerable<string>Lines{ get;}// The line count must be equal to 5 for the model to be valid.[ExactValueAttribute(requiredValue:5)]publicintLineCount=> Lines.Count();
Describe the solution you'd like
An attribute derived from ValidationAttribute that implements the required equality check would be the ideal solution.
Is your feature request related to a problem? Please describe.
It would be interesting to see a solution that supported search by deeply-nested properties. Something like:
classCountry{publicstringName{get;set;}}classManufacturer{publicstringName{get;set;}publicCountryHeadquartersCountry{get;set;}}classCar{publicManufacturerAutoManufacturer{get;set;}publicCountryPlantCountry{get;set;}}// Where one could construct something like: Expression<Func<Car,bool>>exp=x => Car.AutoManufacturer.HeadquartersCountry.Name =="United States";
At some point though, it would be cool to create a query-like language that would allow the user to write statements and save them as searches. Can this be done safely?
Using ExpressionBuilder.GetSearchableMembers<T> only works when the property members are decorated with SearchableAttribute. For EF-generated classes, this makes the method unusable because the property decoration occurs in the metadata class.
Optionally, a call to ExpressionBuilder.GetSearchableMembers<T> returns the member metadata if the decoration occurs in the base class or in the metadata class, provided the property name is the same.
Example
// EF-generated codepublicpartialclassCar{publicstringModelName{get;set;}}// Decorate partial class in separate file so EF DB-first code // generator does not overwrite.[MetadataType(typeof(CarMetdata))]publicpartialclassCar{}publicclassCarMetadata{[Searchable]publicstringModelName{get;set;}}