Problem on mapping custom collection class

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    9 posts
    Member since:
    Mar 2009

    Posted 11 Feb 2010 Link to this post

    Hi,

    I 'm encountered a problem while i'm mapping a property that is a custom collection class Similar post i found in the forum is 
    Strongly typed collection classes and OpenAccess forward mapping

    The solution gave above is changed the data type of property from custom collection class to IList(of Object). But how if i want to maintain the structure of my classes and map it with OA? I want all the collection property refer to a custom collection class, so that i can add some generic function in it.

    These are my classes.

    BusinessBase Class:
    Public MustInherit Class BusinessBase 
        Private _IsValid As Boolean = False 
        Public Property IsValid() As Boolean 
            Get 
                Return _IsValid 
            End Get 
            Set(ByVal value As Boolean) 
                _IsValid = value 
            End Set 
        End Property 
        Public Overridable Sub Validate() 
        End Sub 
    End Class 

    BusinessCollection Class:
    Imports System.Collections.ObjectModel 
    Public Class BusinessCollectionBase(Of T As BusinessBase) 
        Inherits Collection(Of T) 
     
    End Class 

    Guest Class: Here is the Addresses property refered to custom collection class
    <Telerik.OpenAccess.Persistent(IdentityField:="_Guest_Id")> _ 
    Public Class Guest 
        Inherits BusinessBase 
     
        Private _Guest_Id As String = String.Empty 
        Private _FirstName As String = String.Empty 
        Private _LastName As String = String.Empty 
        Private _GuestTypeId As String = String.Empty 
        <Telerik.OpenAccess.Transient()> _ 'Turn off as i don't know how to map it 
        Private _Addresses As AddressCollection 
     
        <Telerik.OpenAccess.FieldAlias("_Guest_Id")> _ 
        Public Property Guest_Id() As String 
            Get 
                Return _Guest_Id 
            End Get 
            Set(ByVal value As String) 
                _Guest_Id = value 
            End Set 
        End Property 
     
        <Telerik.OpenAccess.FieldAlias("_FirstName")> _ 
        Public Property FirstName() As String 
            Get 
                Return _FirstName 
            End Get 
            Set(ByVal value As String) 
                _FirstName = value 
            End Set 
        End Property 
     
        <Telerik.OpenAccess.FieldAlias("_LastName")> _ 
        Public Property LastName() As String 
            Get 
                Return _LastName 
            End Get 
            Set(ByVal value As String) 
                _LastName = value 
            End Set 
        End Property 

        Public Property Addresses() As AddressCollection 
            Get 
                Return _Addresses 
            End Get 
            Set(ByVal value As AddressCollection) 
                _Addresses = value 
            End Set 
        End Property 
     
     
    End Class 

    Address Class:
    <Telerik.OpenAccess.Persistent(IdentityField:="_Id")> _ 
    Public Class Address 
        Inherits BusinessBase 
     
        Private _Id As String 
        <Telerik.OpenAccess.FieldAlias("_Id")> _ 
        Public Property Id() As String 
            Get 
                Return _Id 
            End Get 
            Set(ByVal value As String) 
                _Id = value 
            End Set 
        End Property 
     
        ... 
     
        Private _Guest_Id As String 
        <Telerik.OpenAccess.FieldAlias("_Guest_Id")> _ 
        Public Property Guest_Id() As String 
            Get 
                Return _Guest_Id 
            End Get 
            Set(ByVal value As String) 
                _Guest_Id = value 
            End Set 
        End Property 
     
    End Class 

    AddressCollection Class:
    Public Class AddressCollection 
        Inherits BusinessCollectionBase(Of Address) 
     
    End Class 




  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 16 Feb 2010 Link to this post

    Hello Kevin,
    OpenAccess cannot persist all types of collections because we need some functionality for our lazy loading and change tracking implementation.

    You have to derive your own collection implementation from our TrackedList<T> or TrackedBindingList<T>.

    Sincerely yours,
    Jan Blessenohl
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
Back to Top