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 923871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:15:38+00:00 2026-05-15T19:15:38+00:00

We have a WCF service that uses Entity Framework to query a SQL database.

  • 0

We have a WCF service that uses Entity Framework to query a SQL database. The WCF service is our data access layer. If any of our applications what to read/write data to and from the database, we call a method on the WCF service. The WCF service serializes the EntityObjects to the client apps.

In the client app (e.g. WPF app or ASP.NET app) we may update an entity property and call a WCF service, passing the entity as a parameter, to perform the database update. The entity that was updated may have hundreds of child entities related to it.

For example, a Customer entity will have a Projects property which is a list of Project entities. If our client app changes a simple scalar property on a Customer entity, like CustomerName, we need to save that change to the database by calling an update method on the WCF service. The issue is, we are passing the Customer entity to the service to be updated, but all the attached Projects are also being serialized and passed to the WCF service even though the WCF service update method is only concerned with changes to scalar properties on the Customer entity. Obviously, we are serializing and transferring much more data than is needed.

Has anyone had any experience with this issue? Somehow, I would like to only have the Customer entity serialized back to the WCF service, without doing a deep serialization of the entire object graph.

Thanks.

  • 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-05-15T19:15:39+00:00Added an answer on May 15, 2026 at 7:15 pm

    You could use the maxItemsInObjectGraph property of the DataContractSerializer object to restrict the serialization. You can easily try it by using the configuration element in the behavior configuration. For instance

    <behaviors>
    <behavior name="CustomerUpdate">
    <dataContractSerializer maxItemsInObjectGraph="1" />
    </behavior>
    </behaviors>
    

    One other option I can think of is to create a DataContract Surrogate that removes the info you don’t want serialized. To do so you should create a class that implements the IDataContractSurrogate and use the GetObjectToSerialize method to modify the Customer Entity to not include any of the related entities collections.

    This approach really bothers me for a number of reasons

    • It requires a lot of effort, you may eventually build a behavior to simplify the reuse but that doesn’t avoid the initial effort
    • I can’t think of a generic way of handling this issue for all entities (unless you decide not to send all collection or enumerable properties)

    So I would definitely try to use maxItemsInObjectGraph first

    HTH

    • 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 uses LINQ to SQL for its data layer.
I have a WCF service that accesses a SQL database to fetch data .
I have a WCF service that uses the entity framework to retrieve records from
I have an application that uses Entity Framework to access the data, and throughout
I have a simple WCF project that uses the Entity Framework to access the
I have a wcf service that uses the .net System.AddIns framework to load assemblies
I have a Data Service created using WCF that internally uses nHibernate. This WCF
I have a WCF service that uses ODP.NET to read data from an Oracle
I have client application that uses WCF service to insert some data to backend
I have a very simple (new to this) RESTful WCF service that uses a

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.