Why is using [DataMember(EmitDefaultValue = false)] not recommended?

The reason is at the bottom of the article that you link to. The short version is: When the EmitDefaultValue is set to false, it is represented in the schema as an annotation specific to Windows Communication Foundation (WCF). There is no interoperable way to represent this information. In particular, the “default” attribute in the … Read more

Portable class library: recommended replacement for [Serializable]

Portable Class Libraries (PCLs) now officially deprecated [16 August 2017] If you’re sharing code between different .NET implementations today, you’re probably aware of Portable Class Libraries (PCLs). With the release of .NET Standard 2.0, we’re now officially deprecating PCLs and you should move your projects to .NET Standard. Source: Announcing .NET Standard 2.0 Portable Class … Read more

IsReference property in data contract

It determines how objects are serialized, by default, IsReference=false. Setting IsReference = true allows the serialization of trees of objects that can reference each other. So with a list of Employees that each have a property for Manager (who is also an Employee), a reference to the Manager for each Employee can be held rather … Read more

Serialize enum to string

Using Json.Net, you can define a custom StringEnumConverter as public class MyStringEnumConverter : Newtonsoft.Json.Converters.StringEnumConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { if (value is Action) { writer.WriteValue(Enum.GetName(typeof(Action),(Action)value));// or something else return; } base.WriteJson(writer, value, serializer); } } and serialize as string json=JsonConvert.SerializeObject(container,new MyStringEnumConverter());

WCF: Exposing readonly DataMember properties without set?

Your “server-side” class won’t be “made available” to the client, really. What happens is this: based on the data contract, the client will create a new separate class from the XML schema of the service. It cannot use the server-side class per se! It will re-create a new class from the XML schema definition, but … Read more

When to use DataContract and DataMember attributes?

Since a lot of programmers were overwhelmed with the [DataContract] and [DataMember] attributes, with .NET 3.5 SP1, Microsoft made the data contract serializer handle all classes – even without any of those attributes – much like the old XML serializer. So as of .NET 3.5 SP1, you don’t have to add data contract or data … Read more

Namespace for [DataContract]

DataContractAttribute Class is in the System.Runtime.Serialization namespace. You should add a reference to System.Runtime.Serialization.dll. That assembly isn’t referenced by default though. To add the reference to your project you have to go to References -> Add Reference in the Solution Explorer and add an assembly reference manually.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)