Class UniqueAttribute
Indicates this property must be unique across all instances of that type.
Commonly used on key properties, or names/codes that must be unique
If multiple properties need to be unique together you can use MultipleUniqueAttribute
Inherited Members
Namespace: LemonEdge.API.Attributes.Validation
Assembly: LemonEdge.API.dll
Syntax
[AttributeUsage(AttributeTargets.Property)]
public class UniqueAttribute : DatabaseValidationAttribute
Constructors
UniqueAttribute()
Declaration
public UniqueAttribute()
Properties
AllowNullOrEmpty
Declaration
public bool AllowNullOrEmpty { get; set; }
Property Value
Type | Description |
---|---|
bool |
MergeWithAnyOtherUniqueProperties
If true indicates this property is unique for the item in conjunction with any other properties marked with this being true too
Declaration
public bool MergeWithAnyOtherUniqueProperties { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
GetItemsToCheckFilter(List<IBaseEntity>, IReadOnlyCache)
Declaration
protected virtual Task<QueryableFilter> GetItemsToCheckFilter(List<IBaseEntity> items, IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
List<IBaseEntity> | items | |
IReadOnlyCache | cache |
Returns
Type | Description |
---|---|
Task<QueryableFilter> |
IsValid(object, IEntityUpdater, IReadOnlyCache, UserInfo, ValidationContext)
The validation method to return if the item, and changes, are valid or not
Declaration
protected override Task<ValidationResult> IsValid(object value, IEntityUpdater dbCon, IReadOnlyCache cache, UserInfo user, ValidationContext validationContext)
Parameters
Type | Name | Description |
---|---|---|
object | value | The item to be validated |
IEntityUpdater | dbCon | A connection to the database to use for validation |
IReadOnlyCache | cache | A local cache of current items to speed validation |
UserInfo | user | The current logged in user who made the changes |
ValidationContext | validationContext | The validation context across all changes |
Returns
Type | Description |
---|---|
Task<ValidationResult> | A task holding the validation result |