Search Results for

    Show / Hide Table of Contents

    Class MultipleUniqueAttribute

    Enforces validation that the combination of specified property names must be unique for each instance of this object

    Inheritance
    object
    Attribute
    ValidationAttribute
    DatabaseValidationAttribute
    MultipleUniqueAttribute
    DataSourceUniqueAttribute
    Inherited Members
    DatabaseValidationAttribute.IsValid(object, ValidationContext)
    DatabaseValidationAttribute.RequiresValidationContext
    ValidationAttribute.FormatErrorMessage(string)
    ValidationAttribute.IsValid(object)
    ValidationAttribute.GetValidationResult(object, ValidationContext)
    ValidationAttribute.Validate(object, string)
    ValidationAttribute.Validate(object, ValidationContext)
    ValidationAttribute.ErrorMessageString
    ValidationAttribute.ErrorMessage
    ValidationAttribute.ErrorMessageResourceName
    ValidationAttribute.ErrorMessageResourceType
    Attribute.GetCustomAttributes(MemberInfo, Type)
    Attribute.GetCustomAttributes(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(MemberInfo)
    Attribute.GetCustomAttributes(MemberInfo, bool)
    Attribute.IsDefined(MemberInfo, Type)
    Attribute.IsDefined(MemberInfo, Type, bool)
    Attribute.GetCustomAttribute(MemberInfo, Type)
    Attribute.GetCustomAttribute(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo)
    Attribute.GetCustomAttributes(ParameterInfo, Type)
    Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo, bool)
    Attribute.IsDefined(ParameterInfo, Type)
    Attribute.IsDefined(ParameterInfo, Type, bool)
    Attribute.GetCustomAttribute(ParameterInfo, Type)
    Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(Module, Type)
    Attribute.GetCustomAttributes(Module)
    Attribute.GetCustomAttributes(Module, bool)
    Attribute.GetCustomAttributes(Module, Type, bool)
    Attribute.IsDefined(Module, Type)
    Attribute.IsDefined(Module, Type, bool)
    Attribute.GetCustomAttribute(Module, Type)
    Attribute.GetCustomAttribute(Module, Type, bool)
    Attribute.GetCustomAttributes(Assembly, Type)
    Attribute.GetCustomAttributes(Assembly, Type, bool)
    Attribute.GetCustomAttributes(Assembly)
    Attribute.GetCustomAttributes(Assembly, bool)
    Attribute.IsDefined(Assembly, Type)
    Attribute.IsDefined(Assembly, Type, bool)
    Attribute.GetCustomAttribute(Assembly, Type)
    Attribute.GetCustomAttribute(Assembly, Type, bool)
    Attribute.Equals(object)
    Attribute.GetHashCode()
    Attribute.Match(object)
    Attribute.IsDefaultAttribute()
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    Namespace: LemonEdge.API.Attributes.Validation
    Assembly: LemonEdge.API.dll
    Syntax
    [AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface, Inherited = false, AllowMultiple = true)]
    public class MultipleUniqueAttribute : DatabaseValidationAttribute
    Remarks

    For example:

    [MultipleUnique(new string[] { nameof(Key1), nameof(Key2) }, AllowNullOrEmpty = false)]
    public interface IMyItem
    {
        string Key1 { get; set; }
        string Key2 { get; set; }
        int Value { get; set; }
    }

    Constructors

    MultipleUniqueAttribute(params string[])

    Declaration
    public MultipleUniqueAttribute(params string[] jointUniqueProperties)
    Parameters
    Type Name Description
    string[] jointUniqueProperties

    Properties

    AllowNullOrEmpty

    Indicates that null or empty values are allowed on the referenced JointUniqueProperties

    Declaration
    public bool AllowNullOrEmpty { get; set; }
    Property Value
    Type Description
    bool

    JointUniqueProperties

    The list of properties to ensure the combination of is always unique in the database

    Declaration
    public virtual string[] JointUniqueProperties { get; set; }
    Property Value
    Type Description
    string[]

    TypeId

    Have to override this if AllowMultiple is true

    Declaration
    public override object TypeId { get; }
    Property Value
    Type Description
    object
    Overrides
    Attribute.TypeId

    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

    Overrides
    DatabaseValidationAttribute.IsValid(object, IEntityUpdater, IReadOnlyCache, UserInfo, ValidationContext)

    Extension Methods

    LinqExtensions.AsArray<T>(T)
    LinqExtensions.ToArrayOfOne<T>(T)
    LinqExtensions.ToListOfOne<T>(T)
    MiscExtensions.SetIfNotEqual<T, TP>(T, Expression<Func<T, TP>>, TP)
    WeakReferenceExtensions.WeakReference(object)
    SQLExtensions.ToSQLValue(object, bool)
    ReflectionExtensions.ClearEventInvocations(object, string)
    StringExtensions.ToCSVFormatString(object, Type)

    See Also

    DatabaseValidationAttribute
    In this article
    Back to top © LemonEdge Technologies. All rights reserved.