Data Versioning. Getting Started
Versioning is only supported for business objects based on the Domain Components. To store versions of the business object, you need expand corresponding business class by special properties. This properties are IVersionSupport Domain Component descendants, i.e. are also is Domain Components. Special controllers will provides operations with versions of objects in Views.
- So, firstly you need to define the type of the versioning property. Code snippet below demonstrates this.
- c#
- VB
[DomainComponent]
public interface VersionObject : IVersionSupport
{
string Name { get; set; }
}
<DomainComponent> _
Public Interface VersionObject
Inherits IVersionSupport
Property Name As String
End Interface
For a reference to the such business objects, there are two approaches:
- Standard. The standard way is used to refer to specific version of the business object. It is the RefSpecificVersion property in the example.
- Using a calculated property. It is used to refer to the current version of the business object (depending on the current date). It is the RefCurrentVersion property in the example.
- Now let consider the VersionMainObject business class with references to the versions.
- c#
- VB
[DomainComponent]
public interface VersionMainObject
{
string Name { get; set; }
[Browsable(false)]
Guid? RefLatestVersionId { get; set; }
[NonPersistentDc]
VersionObject RefCurrentVersion { get; set; }
VersionObject RefSpecificVersion { get; set; }
}
[DomainLogic(typeof(VersionMainObject))]
public class VersionMainObjectLogic : DomainLogicBase<VersionMainObject>
{
public VersionMainObjectLogic(VersionMainObject instance)
: base(instance)
{
}
public VersionObject RefCurrentVersion
{
get
{
return VersionHelper<VersionObject>.GetCurrentVersion(this.ObjectSpace, this.Instance.RefLatestVersionId);
}
set
{
this.Instance.RefLatestVersionId = value == null ? (Guid?)null : value.VersionId;
}
}
}
<DomainComponent> _
Public Interface VersionMainObject
Property Name As String
<Browsable(False)> _
Property RefLatestVersionId As Guid?
<NonPersistentDc> _
Property RefCurrentVersion As VersionObject
Property RefSpecificVersion As VersionObject
End Interface
<DomainLogic(GetType(VersionMainObject))> _
Public Class VersionMainObjectLogic
Inherits DomainLogicBase(Of VersionMainObject)
Public Sub New(ByVal instance As VersionMainObject)
MyBase.New(instance)
End Sub
Public Property RefCurrentVersion As VersionObject
Get
Return VersionHelper(Of VersionObject).GetCurrentVersion(Me.ObjectSpace, Me.Instance.RefLatestVersionId)
End Get
Set
Me.Instance.RefLatestVersionId = If(value Is Nothing, CType(Nothing, Guid?), value.VersionId)
End Set
End Property
End Class
See also