Object type DataMembers in WCF DataContract

When we want to create a datacontract with a DataMember of the type 'object' then we have to add the KnownType Attribute for that DataContract so that the serializer will know the types allowed for that generic type.

[KnownType(typeof(string))]
[KnownType(typeof(int))]
[KnownType(typeof(decimal))]
[KnownType(typeof(float))]
[KnownType(typeof(double))]
[KnownType(typeof(bool))]
[KnownType(typeof(char))]
[KnownType(typeof(DateTime))]
[KnownType(typeof(Guid))]
public class RMEntity
{
public ConcurrentDictionary attributes = new ConcurrentDictionary();


[DataMember]
public ConcurrentDictionary Attributes
{
get
{
return attributes;
}

set
{
attributes = value;
}
}



}

Comments

Popular posts from this blog

Responsive Web Design

Contract First Development in WCF 4.5

Affine Cipher in C#