ORM实体XML序列化 [英] ORM Entity Xml Serialization

查看:148
本文介绍了ORM实体XML序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个ORM与.NET中使用,我需要能够做到全图形序列化到XML的ORM生成实体的。我自己的研究使我对使用WCF和实体框架来实现这一目标,这是最好的选择还是有一个更简单的方法?

I am looking for an ORM to use with .net, I need to be able to do full graph serialization to Xml on the entitys the ORM generates. My own research leads me towards using the WCF and the Entity Framework to achieve this, Is this the best option or is there a simpler way ?

推荐答案

那么,大多数ORM工具可以发射标准POCO .NET类,也是最标准的POCO类借给自己的系列化相当不错。例如,LINQ到SQL有通过设置的DataContractSerializer (而不是的XmlSerializer )的支持序列化方式单向。实体框架做同样的(我不认为你需要改变的EF任何设置,虽然)。

Well, most ORM tools can emit standard POCO .NET classes, and most standard POCO classes lend themselves to serialization quite well. For example, LINQ-to-SQL has support for DataContractSerializer (not XmlSerializer) by setting Serialization Mode to Unidirectional. Entity Framework does the same (I don't think you need to change any settings for EF, though).

有关简单 - 嗯,什么是复杂性?建立一个实体框架(或LINQ到SQL)模式通常不是很靠谱。任何具体的是有问题的?

For "simpler" - well, what is the complexity? Setting up an Entity Framework (or LINQ-to-SQL) model isn't usually very tricky. Anything specific being problematic?

需要注意的是XML序列化,在默认情况下,是的的序列化,而不是的的串行器。 的DataContractSerializer 可以支持适当的图表,但你需要启用它(这不是默认的XML模式下启用,因为它产生了非常古怪的XML)。

Note that xml serializers, by default, are tree serializers, not graph serializers. DataContractSerializer can support proper graphs, but you need to enable it (it isn't enabled by default in xml mode, since it produces very odd-looking xml).

您提到WCF;这是一种通信技术;你不提的问题,通讯科,所以目前还不清楚是什么你在这里的意思。请注意,ADO.NET数据服务是另一种选择这里,如果你想基于REST的数据访问,但大多数奥姆斯应该确定与WCF。当然也有替代品。

You mention WCF; that is a communications technology; you don't mention comms in the question, so it isn't clear what you mean here. Note that "ADO.NET Data Services" is another option here, if you want REST-based data-access, but most ORMs should work OK with WCF. There are alternatives, of course.

这篇关于ORM实体XML序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆