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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:10:17+00:00 2026-05-22T20:10:17+00:00

This is what I Have in my WCF service public long Generic_Save(Product p, ObjectSet

  • 0

This is what I Have in my WCF service

public long Generic_Save(Product p, ObjectSet os)
{
    if (p.Id == 0)
    {
        os.AddObject(p);
    }
    else
    {
        // UPDATE
        Product original = os.Single<Project>(o => o.Id == p.Id);

        original.Name = p.Name;

        original.Items = p.Items; // doesn't work !
    }

    dataEntities.SaveChanges();

    return p.Id;
}

Product p is an object from the WCF Call, with an EntityKey etc.. but it’s not attached to the current dataEntities..

What I want to do is to save the object Product p directly, not to get the original from the ObjectSet os before and modify the values -> Product original = os.Single<Project>(o => o.Id == p.Id);

How can I do that?

[EDIT]

I have try this to add new items and it’s working

foreach (Item item in p.Items)
{
    try
    {
        dataEntities.Items.ApplyCurrentValues(item);
    }
    catch (Exception)
    {
        Items i = new Items();

        // Set prop here or make a method CopyTo()
        i.Prop = item.Prop;

        dataEntities.AddToItems(i);
    }
}
dataEntities.SaveChanges();
  • 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-22T20:10:18+00:00Added an answer on May 22, 2026 at 8:10 pm

    Badly. It is possible only with Product p itself (update detached entity) but it is really hard with items. The problem is that you must manually say EF exactly which item has changes, which is new and also which were deleted. The longer discussion of the problem is here. Common solutions are:

    • Do it exactly as you did at the moment but instead of assigning items, manually compare original and received items and modify loaded items accordingly. If you do not add or remove items on the client this should be just about calling ApplyCurrentValues for each item.
    • Use Self tracking entities (only for .NET clients).
    • 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 exposing a single contract and operation: <ServiceContract(Namespace:=ImageSystem)> _ Public
I have this code in my WCF Service: public class MyImage { public Image
I have this WCF service: [ServiceContract] public interface IService { [OperationContract] [WebInvoke(Method = POST,
I have a simple WCF service method: [OperationContract] public SetupGameResult SetupGame(long player1Id, long player2Id,
I have a wcf service defined like this: [OperationContract] [WebInvoke(Method = POST, ResponseFormat =
I have a WCF service application and in this app I am doing calls
I have a WCF service with a function GetData() When my client calls this
I have a WCF service that is deployed on a machine. This WCF service
Greetings, I have a wcf service that exposes functionality to my wpf application. This
I have a WCF web service. I want to send email from this service.

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.