I am trying to map a DTO object to CSLA.NET (see: http://www.lhotka.net/cslanet/ ). For the sake of this question, I am using the sample application that Lhotka provides with its framework. The following is an example of the classes I use (I removed most of the properties and methods for clarity):
<Serializable()> _ Public Class Project Inherits BusinessBase(Of Project) Private mId As Guid = Guid.NewGuid Private mName As String = "" Private mResources As ProjectResources = _ ProjectResources.NewProjectResources() <System.ComponentModel.DataObjectField(True, True)> _ Public ReadOnly Property Id() As Guid <System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _ Get 'CanReadProperty(True) Return mId End Get End Property Public Property Name() As String <System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _ Get 'CanReadProperty(True) Return mName End Get <System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _ Set(ByVal Value As String) 'CanWriteProperty(True) If Value Is Nothing Then Value = "" If mName <> Value Then mName = Value PropertyHasChanged() End If End Set End Property Public ReadOnly Property Resources() As ProjectResources Get Return mResources End Get End Property End Class Public Class ProjectDTO Private _id As Guid Public Property Id() As Guid Get Return _id End Get Set(ByVal value As Guid) _id = value End Set End Property Private _name As String Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Private _resources As New List(Of ProjectResourceDTO)() Public Property MyResources() As List(Of ProjectResourceDTO) Get Return _resources End Get Set(ByVal value As List(Of ProjectResourceDTO)) _resources = value End Set End Property End Class Mapper.CreateMap(Of ProjectDTO, Project)().ConstructUsing(Function(src As ProjectDTO) Project.NewProject()) Mapper.CreateMap(Of ProjectResourceDTO, ProjectResource)() Mapper.CreateMap(Of ResourceDTO, Resource)()
The problem I encountered is related to displaying the readonly Resources property, which is a collection inherited from BusinessListBase. The only way to add items to this collection is to execute the Assign (resourceId) method.
Does anyone have an idea how I can map a DTO object to a CSLA object. That is, how to configure the configurator? Please note that using the resolver for the Resources item did not help in this particular case.
Thanks!
Zen
source share