I've run the DeepData app in VB debugger a few times and have not hit the OrderDto Setter method ... I'm looking into the "back-door" ? approach to setting _lineItems.
So #1 I'm curious about the Use Case where
OrderDTO.LineItems = _LineItemDTOArray
Would be called ....
And am I converting/translating that OrderDTO.LineItems setter method correctly from VB to C# ???
Thanks,
Steve
VB
Private _lineItems As List(Of LineItemDto)
<Xml.Serialization.XmlIgnore()> _
Public ReadOnly Property LineItemsList() As List(Of LineItemDto)
Get
If _lineItems Is Nothing Then
_lineItems = New List(Of LineItemDto)
End If
Return _lineItems
End Get
End Property
Public Property LineItems() As LineItemDto()
Get
Return LineItemsList.ToArray
End Get
Set(ByVal value As LineItemDto())
_lineItems = New List(Of LineItemDto)(value)
End Set
End Property
C#
private List<LineItemDto> _lineItems ;
[System.Xml.Serialization.XmlIgnore()]
public List<LineItemDto> LineItemsList
{
get
{
if (_lineItems == null)
{
_lineItems = new List<LineItemDto>();
}
return _lineItems;
}
}
public LineItemDto[] LineItems
{
get
{
return LineItemsList.ToArray();
}
set
{
_lineItems = new List<LineItemDto>(value);
}
}
}
That code exists to support the serialization process. If you aren't serializing your DTOs (like sending them through a web service) then this code would never be run.
Remember, DeepData illustrates a lot of things, including direct use of a DTO, using a DTO via a web service and using the DTOs created by LINQ. The DTO code supports the first two scenarios, and it is the web service part that you are seeing here.
Web services like arrays better than lists (they often can't serialize lists). But lists are much easier to work with than arrays. So as a pattern, I expose a list for my internal use, and the array property for the XmlSerializer to use.
But if you are using the direct DTO approach, then you'd never serialize the DTOs and this code has no value.
Thanks, Rocky ...
Our plan may include a web service interface, but we are definitely going to be using a remote data portal ....
We'll be passing back a serialized business object, right ?? ... and the framework takes care of that work, right ???
That method is not used for remote calls via WCF ????
Steve
PS .. re the code I supplied ... I was confused by the VB Setter method having a parameter in the signature ...
x.EquipmentItems = SomeEquipmentDTO_GenericList
will work ??? The C# Setter method is coded correctly ????
Yes, the data portal passes serialized objects back and forth.
That is true for all data portal channels, including WCF. The framework (either
.NET and/or CSLA) does take care of all this for you. All you need to do is mark
your objects as Serializable.
VB explicitly defines a parameter to the Set block to avoid
making “value” into a reserved word. C# is the same basic
structure, but the “value” field is a mystical creation of the compiler
J
Rocky
From: tsaltd
[mailto:cslanet@lhotka.net]
Sent: Tuesday, September 18, 2007 11:53 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Translating VB DeepData.DTO.OrderDto.LineItems
Setter to C#
Thanks, Rocky ...
Our plan may include a web service interface, but we are definitely going
to be using a remote data portal ....
We'll be passing back a serialized business object, right ?? ... and
the framework takes care of that work, right ???
That method is not used for remote calls via WCF ????
Steve
PS .. re the code I supplied ... I was confused by the VB Setter method
having a parameter in the signature ...
x.EquipmentItems =
SomeEquipmentDTO_GenericList
will work ??? The C# Setter method is coded correctly ????
Copyright (c) Marimer LLC