datacontracts

Is there any way to hide/flatten base types in WCF service data contracts?

心已入冬 提交于 2020-01-04 19:06:34
问题 Consider the following simple example: [DataContract("{0}Base")] public class Base<T> where T : Entity<T> { // Common methods & properties. No WCF exposed properties } [DataContract] public class Employee : Base<Employee> { // WCF exposed properties } The base class Base has no properties of interest to the WCF service consumers, but WCF forces me to also annotate the Base class with a [DataContract] attribute. This essentially shows up on the service client as Employee : EmployeeBase with

Is there any way to hide/flatten base types in WCF service data contracts?

纵饮孤独 提交于 2020-01-04 19:06:18
问题 Consider the following simple example: [DataContract("{0}Base")] public class Base<T> where T : Entity<T> { // Common methods & properties. No WCF exposed properties } [DataContract] public class Employee : Base<Employee> { // WCF exposed properties } The base class Base has no properties of interest to the WCF service consumers, but WCF forces me to also annotate the Base class with a [DataContract] attribute. This essentially shows up on the service client as Employee : EmployeeBase with

JSON.net not including null properties with EmitDefaultValue false

戏子无情 提交于 2019-12-11 03:37:08
问题 I have a system with many data contracts where the members are decorated with: [DataMember(EmitDefaultValue = false)] I have a case where I need the members to be included when null when serialized to JSON. No matter what serializer settings I choose, I can not get this to work. [TestMethod] public void SerializationTest() { var contract = Activator.CreateInstance(typeof(TestContract)); var formatter = new JsonMediaTypeFormatter { SerializerSettings = new JsonSerializerSettings {

RIA DomainService not generating client code using DataContracts

大城市里の小女人 提交于 2019-12-08 02:37:54
问题 I'm working on a Silverlight 4.0 application and am using RIA services. I have created a class on the server-side which has DataContract and DataMember attributes applied to it. A DomainService exposes this class as a query result and as such, generates code for it on the client. But somehow it doesn't generate code for all properties of the class. Primitive properties of type guid, string, int, bool etc are generated just fine, but if I have a property of my own complex type, that property

Wcf datacontract for classes in a library which i cannot modify

拥有回忆 提交于 2019-12-07 16:23:04
问题 hi i have a class library that which performs methods and has a lot of different classes which it uses as parameters for the methods calls... i am creating a wcf wrapper for this class library. but I do not have permission to change the class library. now my question is how can i expose these classes as data contracts/datamembers easily .. ? I have about 100 different classes which i need for those methods. Thanks 回答1: If you really can't change the library, then I believe your only choice to

RIA DomainService not generating client code using DataContracts

非 Y 不嫁゛ 提交于 2019-12-06 08:48:40
I'm working on a Silverlight 4.0 application and am using RIA services. I have created a class on the server-side which has DataContract and DataMember attributes applied to it. A DomainService exposes this class as a query result and as such, generates code for it on the client. But somehow it doesn't generate code for all properties of the class. Primitive properties of type guid, string, int, bool etc are generated just fine, but if I have a property of my own complex type, that property isn't created on the client. Here's the class in question: [DataContract] [KnownType(typeof(SummaryGroup