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

  • SEARCH
  • Home
  • 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 8066539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:02:47+00:00 2026-06-05T12:02:47+00:00

I have a WCF service that can return several different collections. Objects in each

  • 0

I have a WCF service that can return several different collections.

Objects in each collection can have references to objects in the other collections. Eg. I have a collection of orders, and a collection of customers. Customer objects contain a collection of order references, and each order contains a customer reference.

I was wondering how people generally handle this kind of thing on the client side. As far as I can see, my choices are:

1) Just let WCF serialise any member objects in full, and don’t worry about duplication. I know I can use [PreserveReferences] to mitigate this to some extent, but there is still an awful lot of duplication and unnecessary serialisation going on. Ie, if I request a customer object from the service, it will serialise all members of every order that the customer has, even though I already have those objects on the client side in my orders collection. This also means I must be careful to match things by Id all the time rather than just comparing instances.

2) Serialise Id’s rather than instances. This seems like the most sensible approach, but means I have to have some point where I turn these Id’s into instances again on the client side. This brings a whole mess of where to do this, and how to inject the required repositories to do the wiring up.

3) Just use Id’s everywhere in the client instead of wiring up instances. This just feels wrong to me, and moving away from the whole point of OOP. Instead of accessing a collection on the object, I have to access a collection of id’s and then look them up via some global repository.

At the moment I’m leaning towards 2, but am not liking the serialisation mess this is going to be.

I should note that the client is probably a lot more stateful than most WCF clients, and it maintains an open connection to the service with callbacks etc to maintain its collections, since it is displaying realtime data.

Cheers

  • 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-05T12:02:48+00:00Added an answer on June 5, 2026 at 12:02 pm

    Having 12 months of experience under my belt I thought I would update this with my solution.

    I now use separate DTO objects for serialisation over WCF. Some of these use id’s, some contain full object graphs. The beauty of using DTO’s mean I can return different formats of the same business object depending on the caller’s needs.

    At the client end I effectively have two layers. DTO’s can be used directly straight from the service (by requesting full object graphs containing only what I need), but I also maintain a set of repositories of business objects at the client end. These repos update themselves using DTO’s with just id’s, and the wiring up of references is done at the point the DTO is translated into a business object. As I said in my OP, my client is a lot more stateful than most WCF clients, and the repos also listen for service callbacks with updated objects.

    The result is that client code can use the client repos as if they were running at the service end, and object references can be wired up without duplicating info across the wire.

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

Sidebar

Related Questions

I have a WCF service that can return large amount of data depending on
I have a WCF service that can receive several requests/minute (or seconds) that need
I have a WCF service that can return a stream via a WebGet. This
I have a RESTful WCF service that can return XML, JSON, or JSONP, depending
I have a WCF service that is in turn calling several other web services.
I have a WCF service that I can debug. I put a breakpoint in
I have a WCF service that accepts requests from JQuery. Currently, I can access
Lets say I have a WCF service that a client can use to receive
I have a WCF service. I can return a concrete class without a problem,
I have a WCF service that exposes a bunch of methods that return business

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.