I am getting XML from a dataset that has been populated via a storedprocedure
no schemas have been applied nor any relationships. But the correct table
names have been given to match the table(s) equivalent business object(s). I
have a custom collection that implements ICollection and IEnumerable.
Here is the collection:
Imports ERP.BusinessObjects
Imports ERP.BusinessObjects.Helpdesk
Imports ICTObjects.Collections
Imports System.Xml.Serialization
Namespace Collections
<Serializable()> _
Public Class BusinessObjectCollection : Implements ICollection,
IEnumerable
Private _businessObjectCollection As ArrayList = New ArrayList
Public Sub New()
MyBase.New()
End Sub
Default Public Overloads ReadOnly _
Property Item(ByVal index As Integer) As ERPBusinessObject
Get
Return CType(_businessObjectCollection(index),
ERPBusinessObject)
End Get
End Property
Public Sub CopyTo(ByVal a As Array, ByVal index As Integer) _
Implements ICollection.CopyTo
_businessObjectCollection.CopyTo(a, index)
End Sub
Public ReadOnly Property Count() As Integer Implements _
ICollection.Count
Get
Count = _businessObjectCollection.Count
End Get
End Property
Public ReadOnly Property SyncRoot() As Object _
Implements ICollection.SyncRoot
Get
Return Me
End Get
End Property
Public ReadOnly Property IsSynchronized() As Boolean _
Implements ICollection.IsSynchronized
Get
Return False
End Get
End Property
Public Function GetEnumerator() As IEnumerator _
Implements IEnumerable.GetEnumerator
Return _businessObjectCollection.GetEnumerator()
End Function
Public Function Add(ByVal businessObject As ERPBusinessObject) As
Integer
_businessObjectCollection.Add(businessObject)
Return _businessObjectCollection.Count
End Function
End Class
This collection stores ERPBusinessObject(s) which the business object "Case"
inherits I have the following XML from the dataset:
<BusinessObjectCollection>
<Cases>
<CaseStatus_Status>Request Recieved</CaseStatus_Status>
<ID>1001105</ID>
<SLAAgreement_CallTypeID>Requests</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>CRupa</Owner>
<NatureOfCase>Testing 1</NatureOfCase>
<TimeReported>2005-05-24T12:26:41.8200000+01:00</TimeReported>
<Comments />
<DateCreated>2005-05-24T12:26:41.8200000+01:00</DateCreated>
<Modified>2005-05-24T12:27:00.0000000+01:00</Modified>
<ChangeUser>womber</ChangeUser>
</Cases>
<Cases>
<CaseStatus_Status>Request Recieved</CaseStatus_Status>
<ID>1001106</ID>
<SLAAgreement_CallTypeID>Requests</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>womber</Owner>
<NatureOfCase>Testing 2</NatureOfCase>
<TimeReported>2005-05-24T12:28:40.0430000+01:00</TimeReported>
<Comments>Comment entruy</Comments>
<DateCreated>2005-05-24T12:28:40.0430000+01:00</DateCreated>
<Modified>2005-05-24T15:09:00.0000000+01:00</Modified>
<ChangeUser>womber</ChangeUser>
</Cases>
<Cases>
<CaseStatus_Status>Request Accepted</CaseStatus_Status>
<ID>1001107</ID>
<SLAAgreement_CallTypeID>Requests</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>womber</Owner>
<NatureOfCase>Testing 3</NatureOfCase>
<TimeReported>2005-05-24T12:32:20.0830000+01:00</TimeReported>
<Comments />
<DateCreated>2005-05-24T12:32:20.0830000+01:00</DateCreated>
<Modified>2005-06-19T01:26:00.0000000+01:00</Modified>
<ChangeUser>ME</ChangeUser>
</Cases>
<Cases>
<CaseStatus_Status>Request Accepted</CaseStatus_Status>
<ID>1001108</ID>
<SLAAgreement_CallTypeID>Requests</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>womber</Owner>
<NatureOfCase>Testing 4</NatureOfCase>
<TimeReported>2005-05-24T12:40:10.1670000+01:00</TimeReported>
<Comments>Test</Comments>
<DateCreated>2005-05-24T12:40:10.1670000+01:00</DateCreated>
<Modified>2005-05-24T12:45:00.0000000+01:00</Modified>
<ChangeUser>womber</ChangeUser>
</Cases>
<Cases>
<CaseStatus_Status>On Hold</CaseStatus_Status>
<ID>1001109</ID>
<SLAAgreement_CallTypeID>Network</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>womber</Owner>
<NatureOfCase>Testing 5</NatureOfCase>
<TimeReported>2005-05-24T12:47:33.1270000+01:00</TimeReported>
<Comments>Test</Comments>
<DateCreated>2005-05-24T12:47:33.1270000+01:00</DateCreated>
<Modified>2005-06-21T02:24:00.0000000+01:00</Modified>
<ChangeUser>ME</ChangeUser>
</Cases>
<Cases>
<CaseStatus_Status>On Hold</CaseStatus_Status>
<ID>1001110</ID>
<SLAAgreement_CallTypeID>Network</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>womber</Owner>
<NatureOfCase>Test 6</NatureOfCase>
<TimeReported>2005-05-24T12:55:02.0700000+01:00</TimeReported>
<Comments />
<DateCreated>2005-05-24T12:55:02.0700000+01:00</DateCreated>
<Modified>2005-06-21T02:27:00.0000000+01:00</Modified>
<ChangeUser>ME</ChangeUser>
</Cases>
<Cases>
<CaseStatus_Status>In Progress</CaseStatus_Status>
<ID>1001111</ID>
<SLAAgreement_CallTypeID>Network</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>womber</Owner>
<NatureOfCase>Testing 8</NatureOfCase>
<TimeReported>2005-05-24T13:00:15.8970000+01:00</TimeReported>
<Comments>Test</Comments>
<DateCreated>2005-05-24T13:00:15.8970000+01:00</DateCreated>
<Modified>2005-06-21T02:31:00.0000000+01:00</Modified>
<ChangeUser>ME</ChangeUser>
</Cases>
<Cases>
<CaseStatus_Status>Closed</CaseStatus_Status>
<ID>1001112</ID>
<SLAAgreement_CallTypeID>Intranet Update</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>womber</Owner>
<NatureOfCase>testing</NatureOfCase>
<TimeReported>2005-05-24T13:06:20.3030000+01:00</TimeReported>
<Comments />
<DateCreated>2005-05-24T13:06:20.3030000+01:00</DateCreated>
<Modified>2005-05-24T13:06:00.0000000+01:00</Modified>
<ChangeUser>womber</ChangeUser>
</Cases>
<Cases>
<CaseStatus_Status>Request Recieved</CaseStatus_Status>
<ID>1001113</ID>
<SLAAgreement_CallTypeID>Requests</SLAAgreement_CallTypeID>
<SLAAgreement_Priority>Medium</SLAAgreement_Priority>
<GroupPermissions_GroupID>0</GroupPermissions_GroupID>
<ERPOperator_Name>womber</ERPOperator_Name>
<Owner>womber</Owner>
<NatureOfCase>Test full text</NatureOfCase>
<TimeReported>2005-05-24T13:12:02.7700000+01:00</TimeReported>
<Comments>Test</Comments>
<DateCreated>2005-05-24T13:12:02.7700000+01:00</DateCreated>
<Modified>2005-05-24T13:12:00.0000000+01:00</Modified>
<ChangeUser>womber</ChangeUser>
</Cases>
</BusinessObjectCollection>
I have tried overriding xmlattributes and nothing seems to work. I either
get an error saying the XMLType and XRoot cannot be overridden or the Cases
objects do not get deserialised. If the collection was strongly typed to
Cases it will work but I want this collection to be able to deserialise all
objects that are inherited from ERPBusinessObject. And I also know about
XMLInclude but that only works on objects serialised by .NET. Any ideas or is
this a non-starter. If this does not work I would have to create a custom
collection for every class derived from ERPBusinessObject. Which is horrible.