LINQ to SQL : Enabling .dbml file for WCF
LINQ to SQL is object relational model and .dbml file generates the class file for all kind of Create, read, update and delete (CRUD) through the mapping mechanism. Ideally this should allow us to enable it for WCF Service. But for that we have to manually add DataContract and DataMember attributes. We can use .dbml’s designer feature to add those to our code.
Simply right click on the dbml designer and press F4 to get the property window, you will get a property “Serialization Mode”. Set it to “Unidirectional”. That’s all. This is simple but very helpful.
Now your DataContext and Properties will have the following attributes,
Wherever required. *n indicates the sequence.