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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:39:15+00:00 2026-05-19T02:39:15+00:00

We have a typical multi-tier/layer architecture. Application + WCF Service + Repository/EF4/Database. We are

  • 0

We have a typical multi-tier/layer architecture. Application + WCF Service + Repository/EF4/Database.

We are using a customized version of the EF POCO T4 template to generate our entities, that we use across the tiers/layers. We have decided not to use DTO, because of the additional time/work involved.

An example object would be a forest which could have navigation properties of trees which could have navigation properties of leaves.

What is the best approach to add leaves and deal with the object graph? The data is being imported from the client side, so we don’t necessarily know if the parent forest/tree already exists in the database.

  1. Query service and retrieve any existing related objects. Attach graph for related objects or create new objects and attach graph on the client side.
    example: public Forest GetForest(string forestid)
    then — public void AddLeaf(Leaf leaf)

  2. Create the forest, tree, and leaf objects on the client side and attach the graphs. Send the leaf object across and then on the server side perform logic to compare objects to existing objects in the database. Strip graphs if required, add items that do not exist and/or attach to existing objects.
    example: public void AddLeaf(Leaf leaf)

  3. Create the forest, tree and leaf objects on the client side, but don’t attach the graphs. Send the objects across and then on the service side perform the logic to compare objects to existing objects in the database. Add items that do not exist and/or attach to existing objects.
    example: public void AddLeaf(Leaf leaf, Tree tree, Forest forest)

The question boils down to where should the logic take place to attach the graphs of these related objects.
On a side note I am a little concerned about the “fixup” logic for the navigation properties when dealing with graphs being serialized and deserialized. It seems like that could become an expensive opearation.

Note: The client application is a windows service that is importing data…so it is not necessarily a light weight client. (We are not necessarily afraid of adding logic to it.)

  • 1 1 Answer
  • 4 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-19T02:39:15+00:00Added an answer on May 19, 2026 at 2:39 am

    I had similar question few months ago. After playing a lot with this problem my final decission is to use your third solution (my client is always web application). This solution requires writting a lot of code and it includes some additional database queries because each time you want to update your objects you have to load whole object graph first. Reason for this is that when working with detached objects you have to deal with change tracking manually.

    When you use third solution you can also involve DTO and transfers only really needed data between client and server.

    In case of statefull client (windows app written in .NET or maybe Silverlight) you can also use self tracking entities and your first approach. Self tracking entities are implementation of Changeset pattern. They can track all changes after detaching from context but you have to load your entities first from DB. Self tracking entities are not a good choice in case of web application client or service consumed by non .NET client.

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

Sidebar

Related Questions

I have a typical Silverlight application with a WCF service and I am using
I have typical web application based on PHP, HTML, and javascript. From an HTML
I have a typical Pyramid web application setup. The application directory (I don't know
I have a typical enterprise/business application that I am developing that includes orders, salespersons,
I have a typical dev scenario: I have a SQL 2008 database that I
i have a multi-threaded application which wants to send a sequence of data to
I have a typical pom.xml, and want to print the groupId, artifactId and version,
I have a typical reporting application: Large report <-- HTTP Compression --> ASP.NET Web
I have a typical server in my end and a friend using a client
I have a typical problem with SVN. I did a search in this repository

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.