English 中文(简体)
Automapper vsmap atîtime throughconfig file and reflection
原标题:Automapper vs mapping at runtime via config file and reflection

我是这个专题的新鲜事,我很想知道,我应该做些什么或我如何能够解决下列问题:

我正在开发一个C#网络服务客户,从网络服务的一个数据库检索数据。 网络服务反应将数据作为XML列入一个CDATA要素。 食肉类。 在XML中,是代表一个数据集/浏览的内容。 我只需要使用一个数据集的几个领域。 在检索的数据之后,我必须检查一些业务规则/设想,并将这些领域写到另一个系统。 阅读其他系统的某些价值,检查某些业务规则,并按图解以适当的XML格式将其送回网上服务。

我迄今所做的工作。 我使用了XSD.exe,根据基本图象,生产 c子。 我认为,我有以下选择来开展我的情景工作:

  1. ORM framework: This should be overkill for my app. Or it is not a solution since I don´t communicate with a database directly.

  2. 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?)

  3. 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.

  4. 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?

我的分析是否正确? 我是否误解了什么? 你们会建议什么? 我是否有任何其他选择?

问题回答

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?)

避免因必要修改法典而重建遗嘱的方法不同。 一种办法是积极汇编和使用一个组成部分。 例如,这可以成为源代码。 该决定涉及许多因素,如需要改变的频率,谁将作出改变,业绩如何重要等等。

Another option could be to use xslt to transform the xml input into xml output, but it may depend on what the specific requirements are in your business rules.

我将做的是使用Xml(de)航空化和自动测绘。 将Xml射入物体,使用自动地图仪和您的习惯商业逻辑将来源转换为目的地,然后将目的地物体的编号为Xml。





相关问题
Matrix to Represent a Triangle in Screen Space

So i have a set of four points in 3D Space. P1 [0, 0, 0] P2 [128, 0, 0] P3 [0, 128, 0] P4 [128, 128, 0] Which I m then projecting orthographically to the screen effectively giving me two ...

Using LINQ To SQL with multiple database tables

I have an employee class with as follows: public class Employee { public string FirstName { get; set; } public string LastName { get; set; } public string UserName { get; set; } ...

Mapping points from Euclician 2-space onto a Poincare disc

For some reason it seems that everyone writing webpages about Poincare discs is only concerned with how to represent lines and measure distances. I d like to morph a collection of 2D points (as ...

Fluent NHibernate, varbinary(max) and SQLite

I have a varbinary field in my sql server database that needs to be varbinary(max). I create my database with NHibernate and I use Fluent Nhibernate for my mappings. I also use SQLite for my unit ...

Javascript redirect

I am working with javascript and here is what I am trying to do: 1. Send a get request which looks like "http://localhost:8080/myapp/verify.htm?verifyId=Agkvhs" My requests reaches my verify.jsp in ...

热门标签