What is the difference in WCF when using KnownType and ServiceKnownType?
Posted
by Paul Speranza
on Stack Overflow
See other posts from Stack Overflow
or by Paul Speranza
Published on 2010-03-16T14:39:26Z
Indexed on
2010/03/16
16:31 UTC
Read the original article
Hit count: 667
wcf
|known-types
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.
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.
Thanks, Paul Speranza
© Stack Overflow or respective owner