DataMapper

DataMapper

Old forum URL: forums.lhotka.net/forums/t/7734.aspx


lacuenca posted on Tuesday, October 06, 2009

Hi, all
How can transform from XmlDocument to csla object?

JoeFallon1 replied on Tuesday, October 06, 2009

I don't think that the DataMapper class can handle this.

I suggest that your BO contains a method named LoadData (or something like that) which accepts the XML document as an argument. Then you parse out each value and load it into each BO property (not field) so that your rules for each property get run.

Joe

 

SonOfPirate replied on Tuesday, October 06, 2009

Correct me if I'm wrong, but can't you use the XmlSerializer for this?

 

RockfordLhotka replied on Tuesday, October 06, 2009

You could probably use XmlSerializer or DataContractSerializer to get the XML into an object - from which you could use DataMapper to copy the values into your business object.

XmlSerializer and DCS require the target object to have a public default constructor, and to have only public read/write properties. Most business objects don't meet those criteria, so you can't just deserialize into most business objects directly.

Copyright (c) Marimer LLC