Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:50:21+00:00 2026-06-15T01:50:21+00:00

How to invoke three data contract objects and create it in a single object?

  • 0

How to invoke three data contract objects and create it in a single object?

I have a data contract class like this

 [Serializable]
    [DataContract]
    public class Address
    {
        [DataMember]
        public long AddressId { get; set; }
}

another data contract class like

 [Serializable]
    [DataContract]
    public class Email
    {
        [DataMember]
        public long EmailId { get; set; }
    }

another data contract class like

[Serializable]
    [DataContract]
    public class Phone
    {
        [DataMember]
        public long PhoneId { get; set; }
    }

Now i want to use the AddressId, EmailId, PhoneId in the same method.

How it is possible??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:50:22+00:00Added an answer on June 15, 2026 at 1:50 am

    Please, keep the [DataContract] attrubute only, you don’t need decorating with Serializable as well.

    Well, one have the following options with WCF Data Contracts:

    Composite Data Contracts.

    Member fields of any class marked as DataMember can be data contracts themselves, once they’re decorated with DataContract attribute too. Aggregation of all nested data contracts illustrates the fact that data contracts are recursive in nature. WCF detects all the data contract enabled properties in the object graph and captures their state as well.

    [DataContract]
    class Address
    {
        [DataMember]
        public long AddressId { get; set; }
    }
    
    // The same for the rest two, and then an aggregating type.
    
    [DataContract]
    class Contact
    {
        [DataMember]
        public Address Address {get;set;} // here we go
    
        [DataMember]
        public Email Email {get;set;}
    
        [DataMember]
        public Phone Phone {get;set;}
    }
    

    Data Contract Hierarchy

    Your data contract class may be a subclass of another data contract class, here you just have to explicitly opt-in for a given data contract, i.e. specify the DataContract on each type in the hierarchy tree.

    [DataContract]
    class ContactDetails
    {
        [DataMember]
        public long AddressId { get; set; }
    
        // you could move the phone and email details here too.
    }
    
    [DataContract]
    class Contact : ContactDetails
    {
        [DataMember]
        public string Name { get; set; }
    }
    

    You can’t have three separate classes for each one and inherit from them at once in .Net. And my suggestion is the first case for you – that is data contract aggregation.

    Bonus: Polymorphic Type Reference.

    Applying the [KnownType(Type type)] attribute on a base type for passing polymorphic objects as operation contract arguments. This is definately not your case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C++ invoke explicit template constructor First imagine I have a class Data
this.Invoke((MethodInvoker)delegate { code; }); This results in exception as Cannot access a disposed object.
I have a WCF service operation that accepts a data contract parameter of custom
Is there a way to manually invoke spring binding to create an object based
I have a Core Data model which has three entities: A, B, and C.
I have three activities, say I have the data from ActivityA, and I want
I have a data object that has many different List properties. I want to
This is a study project. I have three database classes A,B,C. There is a
I have a Silverlight Project which passes data using the Data Contract to a
Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.