实体框架 - WCF - 返回JSON怎么做? [英] Entity framework - WCF - return JSON how to do this?

查看:111
本文介绍了实体框架 - WCF - 返回JSON怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有从我的数据库生成的所有POCO实体。我创建了一个IXXX接口,一个XXX类来定义我想从我的服务返回的表的结构,以及一个XXX类来执行查询和返回部分。



我的问题是关于我需要添加到此设置中的元素,以便从我的Web服务返回干净的JSON。



我是一个初学者欢迎所有观点。谢谢!

解决方案

您可以定义具有干净格式的XXXDto类,以满足客户需求。然后将域/终端类映射到Dto对象并使用WCF进行序列化。



或者您可以创建WCF OData服务将服务公开为OData源。


I have all the POCO entities produced from my database. I created an IXXX interface, a XXX class to define the structure of the table I want to return from my service, and a XXX class to do the query and the return part for the interface.

My question is regarding the elements I need to add to this setup in order to return clean JSON from my web service.

I'm a beginner so all points of view are welcome. Thanks!

解决方案

You can define XXXDto classes which are having a clean format for your client needs. And then map the domain/endity classes to Dto objects and serialize them using WCF.

Or you can create WCF OData services to expose the service as OData source.

这篇关于实体框架 - WCF - 返回JSON怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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