The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

MapInheritanceAttribute Class

Specifies the type of object-relational inheritance mapping for the class.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.1.dll

Declaration

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
public sealed class MapInheritanceAttribute : Attribute
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Interface, Inherited:=False)>
Public NotInheritable Class MapInheritanceAttribute
    Inherits Attribute
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
public sealed class MapInheritanceAttribute : Attribute
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Interface, Inherited:=False)>
Public NotInheritable Class MapInheritanceAttribute
    Inherits Attribute

Remarks

XPO supports inheritance and polymorphism of persistent objects. By default, XPO stores descendant-specific persistent properties in separate tables and it automatically joins tables to retrieve object data. To store descendant-specific properties in a base class table, the MapInheritanceAttribute attribute must be applied to the descendant class. Its MapInheritanceAttribute.MapType property must be set to the MapInheritanceType.ParentTable value.

If the MapInheritanceAttribute.MapType property is set to the MapInheritanceType.OwnTable value or if this attribute isn't applied, a new table is created to store the persistent data of descendant objects.

In the example below the MapInheritanceAttribute attribute with its MapInheritanceAttribute.MapType property set to the MapInheritanceType.ParentTable value is applied to the TestContact class. As a result, all persistent fields of TestContact objects will be saved to the table where the persistent data of TestEntity objects is stored.


public class TestEntity: XPObject {
   public TestEntity(Session session) : base(session) { }
   public string Name = "";
}

[MapInheritance(MapInheritanceType.ParentTable)]
public class TestContact: TestEntity {
    public TestContact(Session session) : base(session) { }
    public string FirstName = "";
    public string LastName = "";
}

Inheritance

Object
Attribute
MapInheritanceAttribute
See Also