使用KnownType和ServiceKnownType当WCF的区别是什么? [英] What is the difference in WCF when using KnownType and ServiceKnownType?

查看:558
本文介绍了使用KnownType和ServiceKnownType当WCF的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有返回动物的阵列,但列表可以包含猫,狗等,这些都延长动物的服务。我知道我需要为使用的KnownType或ServiceKnownType属性,并在实体类或服务类,分别为

I have a service that returns an array of animal but the list can contain cats, dogs, etc, which all extend animal. I know I need to use either the KnownType or ServiceKnownType attribute, and on the entity class or the service class, respectively.

2属性之间的区别是什么?我preFER的ServiceKnownType因为它被施加于该服务,它的确切位置是必要的,要求的,而不是KnownType被施加在我的实体。对我来说,把它应用在实体类意味着知道太超前怎么我的实体类被使用。

What is the difference between the 2 attributes? I prefer the ServiceKnownType because it is applied on the service, exactly where it is needed and called for, as opposed to KnownType which is applied on my entity. To me applying it on the entity class means knowing too far ahead how my entity class is being used.

现在我有它在我的实体,它就像一个魅力,但我期待的莅临指导,以最佳实践和有用性。

For now I have it on my entity and it works like a charm, but I am looking for guidance here as to best practices and usefullness.

推荐答案

希望这篇文章会回答你任何问题:

Hopefully this post will answer any questions you have:

http://blogs.msdn.com/sowmy/存档/ 2006/06/06 / 618877.aspx

这篇关于使用KnownType和ServiceKnownType当WCF的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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