Returning Linq queries from wcf.
-
Hello, I'm writing a system where the client application communicates with a wcf-service, and the service in turn uses LinqToSQL to get data from a Sql Server. I want to return the query result back to the client, but to do this I have to define the datacontract. I haven't found a way to do this in the designer. My question is, is it possible to somehow add the attributes from the designer? Adding it manually in the generated code isn't a good solution.
-
Hello, I'm writing a system where the client application communicates with a wcf-service, and the service in turn uses LinqToSQL to get data from a Sql Server. I want to return the query result back to the client, but to do this I have to define the datacontract. I haven't found a way to do this in the designer. My question is, is it possible to somehow add the attributes from the designer? Adding it manually in the generated code isn't a good solution.
The objects generated from the designer are partial classes defined in 2 classes. Part of the class is defined in the generated code side, the other part of the class is all yours: e.g. MyObject.cs <-- put the [DataContract] attribute in this code file MyObject.Designer.cs <--- this one is auto-generated
-
The objects generated from the designer are partial classes defined in 2 classes. Part of the class is defined in the generated code side, the other part of the class is all yours: e.g. MyObject.cs <-- put the [DataContract] attribute in this code file MyObject.Designer.cs <--- this one is auto-generated
I found yet another way @ http://blogs.msdn.com/kaevans/archive/2007/09/03/wcf-and-linq.aspx. "Click on the designer surface in your .dbml file and change the Serialization property to "Unidirectional". That will decorate the generated classes with DataContract and DataMember attributes appropriately."