Search Results for

    Show / Hide Table of Contents
    note

    VeloxDB is still in beta and APIs are subject to change. We are in the process of completing the documentation, so some sections may be incomplete or empty at this time.

    Class HashIndexAttribute

    Apply this attribute to a DatabaseObject class to define a hash index.

    Inheritance
    object
    Attribute
    IndexAttribute
    HashIndexAttribute
    Inherited Members
    IndexAttribute.Name
    IndexAttribute.CultureName
    IndexAttribute.CaseSensitive
    IndexAttribute.IsUnique
    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()
    Attribute.TypeId
    object.GetType()
    object.ToString()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    Namespace: VeloxDB.ObjectInterface
    Assembly: vlxdb.dll
    Syntax
    public sealed class HashIndexAttribute : IndexAttribute

    Remarks

    You can use HashIndexAttribute to create a hash index. Hash index allows you to quickly lookup an object using its properties. After you declare an index with HashIndexAttribute use GetHashIndex<T, TKey1>(string) to fetch a HashIndexReader<T, TKey1> which you can use for object lookup.

    Hash index can also be used to enforce uniqueness constraint on a property. Use IsUnique to declare that index must be unique.

    Support for composite keys is also available, you can specify up to 4 properties to be included in hash index's key.

    Note

    Hash index defined on a base class will also include all subclasses as well.

    Examples

    The following example demonstrates how to create a hash index.

    
    [DatabaseClass]
    [HashIndex("name", true, nameof(City.Name))]
    public abstract class City : DatabaseObject
    {
        [DatabaseProperty]
        public abstract string Name { get; set; }
    
        [DatabaseReference]
        public abstract ReferenceArray<WeatherStation> Stations {get; set;}
    }
    

    The following example demonstrates how to use a hash index.

    HashIndexReader<City, string> reader = om.GetHashIndex<City, string>(nameof(City.Name));
    
    City city = reader.GetObject(name);
    
    if(city == null)
    {
        // City with given name not found.
        return double.NaN;
    }
    
    return city.Stations[0].Temperature.Last();
    

    Constructors

    HashIndexAttribute(string, bool, params string[])

    Declaration
    public HashIndexAttribute(string name, bool isUnique, params string[] properties)
    Parameters
    Type Name Description
    string name

    Index's name

    bool isUnique

    If true, VeloxDB will enforce hash index uniqueness.

    string[] properties

    Names of the properties that hash index should include.

    HashIndexAttribute(string, string, bool, bool, params string[])

    Declaration
    public HashIndexAttribute(string name, string cultureName, bool caseSensitive, bool isUnique, params string[] properties)
    Parameters
    Type Name Description
    string name

    Index's name

    string cultureName

    The name of the culture to use to compare strings inside the index.

    bool caseSensitive

    Indicates whether string comparisons inside the index are case sensitive.

    bool isUnique

    If true, VeloxDB will enforce hash index uniqueness.

    string[] properties

    Names of the properties that hash index should include.

    See Also

    VeloxDB The definitive guide: Hash indexes
    HashIndexReader<T, TKey1>
    HashIndexReader<T, TKey1, TKey2>
    HashIndexReader<T, TKey1, TKey2>
    HashIndexReader<T, TKey1, TKey2, TKey3>
    HashIndexReader<T, TKey1, TKey2, TKey3, TKey4>
    In this article
    © 2025 Copyright: VeloxDB