简体   繁体   English

如何使用WCF和EF进行数据映射

[英]How to do data mapping with WCF and EF

My Question is about returning EF entity using WCF service . 我的问题是关于使用WCF service返回EF实体。 As wcf required Data Members for returning data. 根据wcf要求,数据成员用于返回数据。 Solution i have to do mapping of entity to WCF data members which is quit hectic. 解决方案我必须将实体映射到繁忙的WCF data members Is there possible solution which reduce my work effort. 有没有可能减少我的工作量的解决方案。 I tried EntityFramework with WCF - how to return EF entities but available solution have support for vs2010 only. 我尝试了WCF的EntityFramework-如何返回EF实体,但是可用的解决方案仅支持vs2010。

This is tricky question. 这是一个棘手的问题。 You want to pass EF entities through WCF. 您想通过WCF传递EF实体。 This is bad in some way, because EF objects are burdened with additional data provided by EF (eg for change tracking purposes). 这在某种程度上是不利的,因为EF对象要负担EF提供的其他数据(例如,出于变更跟踪目的)。 The best way to pass objects through domains in your application is create DTO objects. 通过应用程序域传递对象的最佳方法是创建DTO对象。 To do that, you can develop additional mappings (with usage of T4 templates) that create this DTOs based on your existing EF entities. 为此,您可以开发其他映射(使用T4模板),以基于现有EF实体创建此DTO。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM