I have the following (abbreviated) class that is sent and received to/from the client via WCF:
public class Sparetime : ChartConfigurationBase, IChartConfiguration
{
[DataMember]
public int SparetimeConfigurationId { get; set; }
public Single FeederOffRate { get; set; }
}
Notice the first property uses the DataMember attribute and the second doesn't. Am I correct that only the first property would get serialized and sent to the client when a WCF call is made?
Yes, you are right, the MSDN documentation specifies it :
When applied to the member of a type, specifies that the member is part of a data contract and is serializable by the DataContractSerializer.
You should add DataContract attribute to your class to make it serializable :
[DataContract]
public class Sparetime : ChartConfigurationBase, IChartConfiguration
{
}
Note that FeederOffRate
will be set to its default value (null for reference types).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.