Yanshof
Yanshof

Reputation: 9926

Can't set default value to DataMember

I have class that is a DataContract and the member values are holding default values. When i create object of this type in the client machine i don't see that the default values are set.

The Class:

[DataContract]
public class ServiceControl
{
    [DataMember(EmitDefaultValue = false)]
    public decimal Value1 = 1.0m;

    [DataMember( EmitDefaultValue = false )]
    public decimal Value2 = 1.0m;
}

Upvotes: 1

Views: 1124

Answers (1)

Aliostad
Aliostad

Reputation: 81680

Most probably since you are using a "Add Service Reference". This will only copy the definition using WSDL and will not contain any code or business logic in your classes.

UPDATE

You can reuse your0 DTO/Entities:

  • Clicking the box reuse types from referenced assemblies and making sure you are referencing the assembly defining DTO
  • Reference assembly and create your proxies using channel factory

Upvotes: 2

Related Questions