Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. A question on wcf and composite objects

A question on wcf and composite objects

Scheduled Pinned Locked Moved C#
helpcsharpdatabasewcfsales
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Eber
    wrote on last edited by
    #1

    This is my scenario: I have a huge database and I'm building numerous services to access the data. Each service exposes a unique set of data and services to the consumer. So for an object such as Company our internal service needs the raw address in the composite. However our portal service need fully enumerated Address info in the composite. I wanted to avoid having a massive object with various composite addon's that don't apply to a given object but I'm running into difficulties. First I decided that each composite builder class will be in a namespace deeper than the data namespace. So instead of myApp.Data it would be myApp.Data.Mainservice and myApp.Data.Portalservice for the composite objects. My next step was to inherit Company, add a constructure that takes Company as input to populate internal fields, and add the DataMember for each Composite that is needed. Works great but I get a runtime error that I cannot inherit an object that is not marked as Serializable or DataContract. Initially I just added a public partial class Customer and added the DataContract attribute, but that does not expose the DataMembers inside of the object. I also cannot use the partial class definition as I need to be inside the namespace of the Customer object which puts me back into the same problem of having an accumulation of composite objects. For those who need pictures here is the code I want to implement:

     namespace Company.Data.InternalServices
     {
          \[DataContract\]
          public sealed class CompositeLocation : Company.Data.Location
          {
    
                \[DataMember\]
                public Address LocationAddress{get;set;}
           
           }
     
    
     \[ServiceContract\]
     public class InternalContract:IInternalContract
     {
          \[OperationContract\]
          public CompositeLocation GetLocation( Guid LocationIdentity );
     }
    
     }
    
     namespace Company.Data.Portal
     {
           \[DataContract\]
           public sealed class CompositeLocation:Location
           {
                 \[DataMember\]
                  public EnumeratedAddress{get;set;}
            }
    
           \[ServiceContract\]
           public class PortalContract:IPortalContract
           {
                \[OperationContract\]
                public CompositeLocation GetLocation(Guid LocationIdentity);
            }
      }
    

    When no method returns a Location, WCF drops the DataContract for Location. I want to force it to keep Lo

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups