Creating and Binding a BO to an XML file...


Author
Message
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
I'm sorry I didnt see anything in the documentation that talks about how to create and ultimately bind a BO to an XML file. I looked at the XMLDataSourceSample and I saw that you did it, I just dont understand how to get to that point. I'm assuming you cant use the Business Object Mapper to map to the xml file and create the partial class.



Could you maybe help me get a jump start on how to do this?



Thanks
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You have to use the DDT and create a "dummy" profile with a "dummy" database and a "dummy" tables that has the structure of the XML file.  That's how you get the BOMapper to create the partial class for you.
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
We didnt purchase the DDT... does that mean we are out of luck? What if I initially create the table in SQL Server to get the BO Mapper to create the partial class and then some how redirect the BO to the xml file instead of SQL Server
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, that will work as well... you could even create the structure on a local instance of SQL Server express rather than on one of your dev servers... doesn't matter.
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Ok, now that I have my BO created what would I need to change to redirect it to look at the xml file instead of the SQL Server?
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You will need to write Fill methods that end up calling Me.CurrentDataTable.ReadXml() to bring the xml file in and you will need to overwrite the Save() method to save the data to the XML file using Me.CurrentDataTable.WriteXml() and then Me.CurrentDataTable.AcceptChanges().
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Thanks. Me.CurrentDataTable.ReadXML() didnt work but I was able to take most of the code from the XMLDatasource example and make it work.



Another question...what if I wanted to create a FillByEmployeeID method? how would I query the XML document to only return the records I want?



Here's the code I used for my basic Fill method:





Public Sub FillAll()

'-- Establish Locals

Dim loDS As New DataSet

Dim lcFile As String = MicroFour.StrataFrame.Strings.StringBasics.AddBS(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))



lcFile &= "test.xml"



'-- Load the XML file

loDS.ReadXml(lcFile)



'-- Move the data into the business object

Me.CopyDataFrom(loDS.Tables(0), MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)



'-- Clean Up

loDS.Dispose()

End Sub


StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
That is an excellent question, Mike...

I would venture to say that you would want to copy the data from the XML file into SQL Server and run the query BigGrin

No, really, you'll probably need to use some of the objects within the System.Xml.XPath namespace (in the System.Xml.dll assembly) or maybe figure out how to use XQuery... however I have never used either of those technologies, so I wouldn't know where to start, though you might Google XQuery or XPath and see what sort of info you can find on it.

The XPath namespace has some objects you can use to create an XML cursor, so if worst comes to worst, you could cursor through the records to find the one that you want, but I'm pretty sure XQuery supports XML indexes, so it should be lots faster.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search