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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:50:58+00:00 2026-05-20T10:50:58+00:00

I have a save function for my order entity that looks like this and

  • 0

I have a save function for my order entity that looks like this and it breaks on the sumbmitChanges line:

public void SaveOrder ( Order order ) {
    if (order.OrderId == 0)
        orderTable.InsertOnSubmit(order);
    else if (orderTable.GetOriginalEntityState(order) == null) {
        orderTable.Attach(order);
        orderTable.Context.Refresh(RefreshMode.KeepCurrentValues , order);
    }
    orderTable.Context.SubmitChanges();
}

The order entity contains two other entities; an Address entity and a credit card entity. Now i want these two entities to be null sometimes.

Now my guess for why this is throwing an error is because that both of these entites that are inside order are null. If this is the case, How can I insert an new order into the database with both entities (Address and creditCard) being null.

Edit:

So i deleted the credit card entity and address entity for now, but i realized what is causing the problem. The order has a collection of Images (an Image is an entity), and it throws the error because (im assuming), that i cant insert a new order with the order having a bunch of images that already exist. So i know what the problem is, but i have no idea how to fix it. Any help would be much appreciated. 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-20T10:50:59+00:00Added an answer on May 20, 2026 at 10:50 am

    Did your image entities come from a different DataContext? As long as they come from the same DataContext that your are using to save your order it should not try to add them again.

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

Sidebar

Related Questions

i have a class like this: class myclass { public function save($params){ // some
I have a function that receives a string of tags. In order to save
I have a html table that looks something like this <table id=eventTable> <thead> <tr><th>#</th><th>Options</th></tr>
I have code that uses Win API function RegSaveKeyEx to save registry entries to
I have a simple unsubscribe function in my Unsubscribed controller. if ($this->Unsubscribe->save($this->data['Unsubscribes'])) { //
So I have this function that gets data from database and echoes it. The
I have an application that allows users to save events. I would like to
I have this problem understanding how to save data in order to have an
i have the following function to override the default save function in a model
I have the following code: <script type=text/javascript> $(document).ready(function() { $(#Save).click(function() { $.post(url, { data:

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.