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 InverseReferencesAttribute

    Specifies that the property represents an inverse reference.

    Inheritance
    object
    Attribute
    InverseReferencesAttribute
    Inherited Members
    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 InverseReferencesAttribute : Attribute

    Remarks

    When you define a reference between two classes using DatabaseReferenceAttribute, you can also define an inverse reference on the target class. Inverse reference enables you to navigate a reference in reverse direction. To declare an inverse reference declare a property of InverseReferenceSet<T> type and mark it with InverseReferencesAttribute.

    Note

    TrackInverseReferences must be set to true for the reference if you want to use inverse references.

    Examples

    The following example demonstrates how to declare an InverseReferencesAttribute property.

    [DatabaseClass]
    public abstract class Blog : DatabaseObject
    {
        [DatabaseProperty]
        public abstract string Url { get; set; }
    
        [InverseReferences(nameof(Post.Blog))]
        public abstract InverseReferenceSet<Post> Posts { get; }
    }
    

    The following example demonstrates how to use an inverse reference.

    [DbAPIOperation]
    public bool TestBlog(ObjectModel om)
    {
        bool result = true;
        // Create new blog.
        Blog blog = om.CreateObject<Blog>();
    
        // Create a new post.
        Post post1 = om.CreateObject<Post>();
    
        // Add a new post using direct reference.
        post1.Blog = blog;
    
        // Create another post.
        Post post2 = om.CreateObject<Post>();
    
        // Add another post to the blog, using inverse reference.
        blog.Posts.Add(post2);
    
        // Check if both posts are in blog
        result &= blog.Posts.Contains(post1);
        result &= blog.Posts.Contains(post2);
    
        // Check if both posts reference blog
        result &= post1.Blog == blog;
        result &= post2.Blog == blog;
    
        // Clear all posts
        blog.Posts.Clear();
    
        // Confirm that posts are not in blog anymore.
        result &= !blog.Posts.Contains(post1);
        result &= !blog.Posts.Contains(post2);
    
        // Check if both posts point to null.
        result &= post1.Blog == null;
        result &= post2.Blog == null;
    
        // Delete posts.
        post1.Delete();
        post2.Delete();
    
        // Delete blog.
        blog.Delete();
    
        return result;
    }
    

    Constructors

    InverseReferencesAttribute(string)

    Declaration
    public InverseReferencesAttribute(string propertyName)
    Parameters
    Type Name Description
    string propertyName

    Name of the property that represent's the direct reference.

    Properties

    PropertyName

    Get's the name of the direct reference property.

    Declaration
    public string PropertyName { get; }
    Property Value
    Type Description
    string

    See Also

    DatabaseReferenceAttribute
    InverseReferenceSet<T>
    In this article
    © 2025 Copyright: VeloxDB