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 SupportPolymorphismAttribute
Apply this attribute to automapper method to specify that it supports polymorphism
Inheritance
Namespace: VeloxDB.ObjectInterface
Assembly: vlxdb.dll
Syntax
public sealed class SupportPolymorphismAttribute : Attribute
Remarks
AutoMapper methods by default don't support polymorphism. This is because polymorphism support introduces slight performance overhead. In order to support polymorphism, mark the automapper methods with SupportPolymorphismAttribute. If you don't mark the base methods with SupportPolymorphismAttribute automapper generator will prevent you from extending the base class. The derived class must contain all automapper methods that the base class contains. DTO Type should be the DTO Type of the derived class, not base class. Automapper uses this information in order to determine which database type maps to which DTO. For more detailed overview of automapper see Database APIs section of the guide.
Examples
The following example demonstrates how to declare an automapper method that supports polymorphism.
using VeloxDB.ObjectInterface;
namespace University;
[DatabaseClass(true)]
public abstract partial class Person : DatabaseObject
{
[DatabaseProperty]
public abstract string Name { get; set; }
[DatabaseProperty]
public abstract string Address { get; set; }
[SupportPolymorphism]
public partial PersonDTO ToDTO();
[SupportPolymorphism]
public static partial Person FromDTO(ObjectModel om, PersonDTO dto);
}
And here you can see how to specify automapper methods in derived class.
using VeloxDB.ObjectInterface;
namespace University;
[DatabaseClass]
public abstract partial class Student : Person
{
[DatabaseReference]
public abstract ReferenceArray<Course> Courses { get; set; }
[DatabaseProperty]
public abstract DatabaseArray<int> Scores { get; set; }
public new partial StudentDTO ToDTO();
public static partial Student FromDTO(ObjectModel om, StudentDTO dto);
}
Constructors
SupportPolymorphismAttribute()
Declaration
public SupportPolymorphismAttribute()