.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

using inheritance in datacontract

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :WCF
 

HI,

Can i use inhericance in datacontract, so that i can define common properties under multiple datacontrace classes under a base class

I have multiple service methods in which some of the properties in datacontract are same. I want to create a base class with all the common properties for datacontract then specialized classes deriving from the this base class and adding extra properties as per their requirement.

But when i generate a proxy the base class properties are not coming directly on the child class, in proxy I have to do specilizedClass.Base.property. Is there a way, to generate a proxy class, such that child class direcly contains all the properties of base class.

Regards


singhhome


View Complete Post


More Related Resource Links

using inheritance in datacontract

  

HI,

Can i use inhericance in datacontract, so that i can define common properties under multiple datacontrace classes under a base class

I have multiple service methods in which some of the properties in datacontract are same. I want to create a base class with all the common properties for datacontract then specialized classes deriving from the this base class and adding extra properties as per their requirement.

But when i generate a proxy the base class properties are not coming directly on the child class, in proxy I have to do specilizedClass.Base.property. Is there a way, to generate a proxy class, such that child class direcly contains all the properties of base class.

Regards


singhhome

Master Pages: Master Your Site Design with Visual Inheritance and Page Templates

  

Master pages in ASP.NET 2.0 solve a problem many Web developers have been solving on their own with a variety of techniques for years - providing a single master template for an entire site. This article covers the details of master pages, discussing their usage and implementation and how they are a natural evolution of custom techniques developers are using today.

Fritz Onion

MSDN Magazine June 2004


Problems with inheritance in WCF

  
Hi, I've got some code written using remoting that I'm considering updating to use WCF as WCF has some pretty nice features, however I've been having real problems getting inheritance to work going across WCF using binary serialization, I created some simple test code to get my head round whats going on using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.ServiceModel; using System.ServiceModel.Channels; namespace Test { [ServiceContract] public interface IServer { [OperationContract] BaseType Get(); } public class Server : MarshalByRefObject, IServer { public BaseType Get() { return new InhertitedType(); } } [Serializable] public abstract class BaseType { public abstract string Name{ get;} } [Serializable] public class InhertitedType : BaseType { public override string Name{ get { return "Working"; } } } class Program { static int port=8888; static string ip = "127.0.0.1"; static void Main(string[] args) { var binding = new NetTcpBinding(); var endpoint = new EndpointAddress(string.Format("net.tcp:/

Is it a good practice to use DataContract attributes on business entities

  
Hi Folks, Currently I am developing a framwork for travel industry and finally my framework will expose its operations in the form of WCF Service. I was wondering if it is a good idea to decorate your entities and class with DataContract attributes. I know this is required if you want your classes/fields to be serialized/deseralized.  However, by Adding these attributes mean you are making your entities service specific which I believe not a good idea. Service and domain specific entities should be seperate. One solution to this would be to make DTOs and decorate them with these attributes and this make sense as core purpose of these DTOs is serialization and deserialization. What can be other options....? Please share your thoughts. Thanks, Naeem

Problem: DataContract and DataMember attributes are not being recognized

  
I am having a strange problem. My service is otherwise working fine. However, now I want to add a custom object to be sent over to clients. I created a class to hold the data applied DataContract and DataMember attributes. However, compiler is not recognizing these attributes and giving me following error. The type or namespace name 'DataContractAttribute' could not be found (are you missing a using directive or an assembly reference?)  I could not figure our what assembly do I need to refer to. I am using VS2010 on WinXP. Thanks. kr

Can someone explain this inheritance?

  
I am having trouble understanding the inheritance listed in http://msdn.microsoft.com/en-us/library/cc406686(office.12).aspx <%@ Page Debug="true" Language="C#" MasterPageFile="~/_admin/admin.master" Inherits="MSDN.SharePoint.Samples.WarmupJobManager, MSDN.SharePoint.Samples.SharePointWarmupJob, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7fd1d26c5854f031" %> It almost looks to me like two classes are being inherited - WarmUpJobManager AND SharepointWarmupJob. Is this correct?...or even possible?? Neither class is a partial class. Sorry I am new to this and was trying to deploy this example but the inheritance displayed here has me confused. Thanks in advance, Jake.

How can I reset inheritance to regain controll of a subsite/subweb?

  
How can I reset inheritance to regain controll of a subsite/subweb?Kevin W. Gagel

ViewModel and inheritance.

  
Let's say I get DataContract class from a Service reference. Now I want to use this class in a viewmodel because I need extended functionality. Can you guys recommend if the ViewModel class should inherit the class from the service or should the viewmodel have the class as a property instead? I've used both these approaches but I'm more and more thinking that using the class as property instead of inherit it is an easier way. Thanks for help!

WCF Service "DataContract" conflict error

  
Hi,I am consuming two wcf services in my workflow. The services have the same datacontract with name "Consumer".My Workflow building successfully, But when i am trying to publish my workflow i am getting the "consumer" datacontract conflit error. The error is :DataContract for type 'Service1.Consumer' cannot be added to DataContractSet since type 'Service2.Consumer' with the same data contract name 'Consumer' in namespace 'http://MyWorkflow' is already present and the contracts are not equivalent.Suggest me how to solve this conflict.Thanks in advance.

How do i pass my datacontract into my business layer without a circular reference????

  
Ok, this architecture is fairly new to me, so I need a few good pointers.  I've searched the topic, but still don't have a clear understanding on what I'm missing.   I have a presentation layer, which displays my data and forms. I have a WCF service, a business layer and a dataAccess Layer I am trying to read data from on OLD!! foxpro .dbf file.  I've read all the articles on why not pass Datasets, etc so I'm trying to learn how to pass data contracts.  I have the following in my WCF [ServiceContract] public interface IService1 { [OperationContract] void SaveNDFData(string storedprocedure, ndfContractLibrary.NDFDataParam[] ndfData); <strong>[OperationContract] List<ndfContractLibrary.NDFDRawData> getRawNDFD();</strong> } I have a separate library for my dataContracts as i know later I will have several.  I'm using this as a generic List<> [Serializable] [DataContract] public class NDFDRawData { private int batchNumber; [DataMember] public int BatchNumber { get { return batchNumber; } set { batchNumber = value; } } private int sampleNumber; [DataMember] public int SampleNumber { get { return sampleNumber; } set { sampleNumber = value; } } private decimal invitroHour; [Da

Different DataContract in Response

  
Hi, I want to expose different data contaract because passing collection of data to service and process the data if any error occured then i add different contract for error message Thanks, Sen

DataContract & json i dont know how to do this...

  
Hello,at work we are migrating all the application to .Net 4.0 and leaving behind the Newtonsoft json serializer with the Microsoft serializer.the thing is that in Newtonsoft you have a couple of attributes that apply to my needs.JsonObject(MemberSerialization.OptIn) <--- this makes that only serialize the properties that have the following attribute.JsonProperty("id")Is there a way of accomplish the same with datacontract or something???i dont want to make a custom converter, i have plenty of classes and make custom converters to all of them, its impossible...well... thanks for any info...greetings!!!
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend