I am using latest version 1.0.2004.1 version.
But I got the problems for the following XML saving and loading functions.
The saving is always working, but the loading gives errors if there is data for the related table.
the shema is like following:
Customer has 0 or 1 CustAdditional info. If the CustAdditional is 0 (ie. no data), the loading is ok. otherwise the error occurs.
Error happens in this line in loading method:
collection.ReadXml(doc.OuterXml)
"The field is marked readonly and cannot be changed."
" at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Xml2Entity(XmlNode node, Hashtable processedObjectIDs, ArrayList nodeEntityReferences)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.Xml2EntityCollection(XmlNode node, Hashtable processedObjectIDs, ArrayList nodeEntityReferences)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.ReadXml(XmlNode node)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.ReadXml(String xmlData)
at XMLIO.loadXMLCollection(EntityCollectionBase& collection, String filename) in D:\WMS\WMSAF3.0-SourceCode\CSMAT\CSMAT.DAL\XMLIO.vb:line 198
at CSMAT.GUI.ModuleFacade.LoadXMLCustomer() in D:\WMS\WMSAF3.0-SourceCode\CSMAT\CSMAT.GUI\ModuleFacade.vb:line 137"
Public Shared Sub saveXMLCustomerCollection(ByRef collection As CustomerCollection)
Dim path As String = getPath("Customer")
collection.SupportsSorting = True
Dim prop As EntityPropertyDescriptor = New EntityPropertyDescriptor(EntityFieldFactory.Create(CSMAT.DAL.CustomerFieldIndex.CustId), GetType(CustomerEntity))
collection.ApplySort(prop, System.ComponentModel.ListSortDirection.Ascending)
Dim xml As New xml.XmlDocument
Dim node As xml.XmlNode
Dim xmls As String
collection.WriteXml("CustomerEntityCollection", xmls)
xml.LoadXml(xmls)
'Testing the existance of the destination path
Dim dir As System.IO.Directory
Dim dstring As String = getDIR()
If Not dir.Exists(Application.StartupPath & dstring) Then
dir.CreateDirectory(Application.StartupPath & dstring)
End If
xml.Save(Application.StartupPath & path)
End Sub
Public Shared Function loadXMLCollection(ByRef collection As EntityCollectionBase, ByVal filename As String) As Boolean
Dim path As String = getPath(filename)
Dim file As System.IO.File
If file.Exists(Application.StartupPath & path) Then
Dim doc As New Xml.XmlDocument
doc.Load(Application.StartupPath & path)
collection.ReadXml(doc.OuterXml)
Cursor.Current() = System.Windows.Forms.Cursors.Default
Return True
End If
Return False
End Function
Attachments
Filename |
File size |
Added on |
Approval |
Customer(error).xml
|
25,192 |
20-Nov-2008 18:08.56 |
Approved |