我是这个专题的新鲜事,我很想知道,我应该做些什么或我如何能够解决下列问题:
我正在开发一个C#网络服务客户,从网络服务的一个数据库检索数据。 网络服务反应将数据作为XML列入一个CDATA要素。 食肉类。 在XML中,是代表一个数据集/浏览的内容。 我只需要使用一个数据集的几个领域。 在检索的数据之后,我必须检查一些业务规则/设想,并将这些领域写到另一个系统。 阅读其他系统的某些价值,检查某些业务规则,并按图解以适当的XML格式将其送回网上服务。
我迄今所做的工作。 我使用了XSD.exe,根据基本图象,生产 c子。 我认为,我有以下选择来开展我的情景工作:
ORM framework: This should be overkill for my app. Or it is not a solution since I don´t communicate with a database directly.
Automapper: Seems to be a good solution. But I think it is not that flexibel like my 3. option (see beyond). If an error in the mapping is detected after my app was deployed, I have to rebuild the app. Another negative point would be, if the schema changes, I would have to rebuild my app again. (Or do I have always adapt my app according to the schema?)
Via custom mapping file and reflection: I am not sure if this is really realizable, but it would be the most flexible solution in my opinion. The solution would be similar to this http://www.techrepublic.com/article/applied-reflection-dynamically-accessing-properties-of-a-class-at-runtime/6099345 If I understood this article correct, then there would be a config file that maps the type of class and its properties to destination types, for example: SourceClassType=ClassA, SourcePropertyName=PropA->DestinationClassType=ClassB, DestinationPropertyName=PropX.
Linq2Xml: With Linq2Xml I could extract the required data from the XML and put it in my own defined classes. But how would I put data back into the XML according to schema that the web service expects?
我的分析是否正确? 我是否误解了什么? 你们会建议什么? 我是否有任何其他选择?