'Here is the code...
'Classes to abstract a FILE entity that is persisted in the databas
Imports System.Xml.Serializatio
Imports dalWAP.dalWA
'A worker class to get the data from the Database and save it bac
Public Class egFil
Sub New(
End Su
'Get a collection of FILE entities from the databas
Public Function GetCollection(Optional ByVal FileID As Integer = -1) As clFil
Dim dsFiles As DataSe
Dim serializer As XmlSerialize
Dim oXML As Xml.XmlDataDocumen
Dim oclFile As clFil
Dim oXMLr As Xml.XmlNodeReade
'-------
'this is the line that gives the erro
'You must implement a default accessor on brWAP.clFile because it inherits from ICollection
'-------
serializer = New XmlSerializer(GetType(clFile)
'Call the data access layer to pysically read from the DB to a datase
dsFiles = GetFiles(FileID
'load the dataset into an xml documen
oXML = New Xml.XmlDataDocument(dsFiles
oXMLr = New Xml.XmlNodeReader(oXML
'deserialise the xml into a collection of FILE entitie
oclFile = CType(serializer.Deserialize(oXMLr), clFile
End Functio
End Clas
'Strongly Typed collection of FILE entitie
<XmlType(TypeName:="clFile")>
Public Class clFil
Inherits System.Collections.Specialized.NameObjectCollectionBas
Public Sub New(
'default constructo
End Su
Public Function Add(ByVal value As cdFile) As Boolea
Me.BaseAdd("_" & value.FileID, value
End Functio
<XmlElementAttribute("cdFile", GetType(cdFile))>
Default Public Overloads ReadOnly Property Item(ByVal Key As String) As cdFil
Ge
Return Me.BaseGet("_" & Key
End Ge
End Propert
Public Function ItemAt(ByVal value As Integer) As cdFil
Return Me.BaseGet(value
End Functio
Public Function Remove(ByVal value As Integer) As cdFil
Dim ocdFile As cdFil
ocdFile = Me.Item(value
Me.BaseRemove("_" & value
Remove = ocdFil
ocdFile = Nothin
End Functio
Public Function RemoveAt(ByVal value As Integer) As cdFil
Dim ocdFile As cdFil
ocdFile = Me.ItemAt(value
Me.BaseRemoveAt(value
RemoveAt = ocdFil
ocdFile = Nothin
End Functio
End Clas
'<summary
'<para>Represents a FILE entity</para
'<para>A FILE entity implemnts a reference to an external file</para
'</summary><XmlType(TypeName:="cdFile")>
Public Class cdFil
Private mintFileID As Intege
Private mstrTheName As Strin
Private mstrThePath As Strin
Private mblnNew As Boolea
Private mblnDirty As Boolea
Private mblnDeleted As Boolea
Overrides Function GetHashCode() As Intege
Return mintFileID.GetHashCod
End Functio
'<summary
'<para>If record ID's are equal, objects are equal</para
'</summary
Overloads Function Equals(ByVal ID As Integer) As Boolea
If mblnNew The
Return Fals
Els
Return (ID = mintFileID
End I
End Functio
Overloads Function Equals(ByVal Test_cdFile As cdFile) As Boolea
If mblnNew The
Return Fals
Els
If Test_cdFile Is Nothing The
Return Fals
Els
Return (mintFileID = Test_cdFile.FileID
End I
End I
End Functio
'<summary
'<para>new instance of existing record</para
'</summary
Sub New(ByVal FileID As Long, ByVal TheName As String, ByVal ThePath As String
mintFileID = FileI
mstrTheName = TheNam
mstrThePath = ThePat
mblnDirty = Fals
mblnNew = Tru
End Su
'<summary
'<para>for a really new file</para
'</summary
Sub New(ByVal TheName As String, ByVal ThePath As String
mstrTheName = TheNam
mstrThePath = ThePat
mblnNew = Tru
mblnDirty = Tru
End Su
'<summary
'<para>empty constructor for xml de-serialisation</para
'</summary>
Sub New()
mblnNew = False
mblnDirty = False
End Sub
Public Overloads Function Saved() As Boolean
mblnDirty = False
Return True
End Function
Public Overloads Function Saved(ByVal FileID As Long) As Boolean
mblnDirty = False
mblnNew = False
mintFileID = FileID
Return True
End Function
Public Function Delete() As Boolean
mblnDeleted = True
Return mblnDeleted
End Function
<XmlIgnore()> _
Public ReadOnly Property Dirty() As Boolean
Get
Return mblnDirty
End Get
End Property
<XmlIgnore()> _
Public ReadOnly Property Deleted() As Boolean
Get
Deleted = mblnDeleted
End Get
End Property
Public Property FileID() As Integer
Get
Return mintFileID
End Get
Set(ByVal Value As Integer)
mintFileID = Value
End Set
End Property
Public Property TheName() As String
Get
Return mstrTheName
End Get
Set(ByVal Value As String)
mstrTheName = Value
End Set
End Property
Public Property ThePath() As String
Get
Return mstrThePath
End Get
Set(ByVal Value As String)
mstrThePath = Value
End Set
End Property
End Class