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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:01:59+00:00 2026-05-10T18:01:59+00:00

I work on a web game , I use asp.net mvc, linqtosql. I have

  • 0

I work on a web game , I use asp.net mvc, linqtosql.

I have 3 tables that store default game values: DefaultRegions, DefaultSubRegions and DefaultCountries. These 3 tables are related to each other thanks to primary / foreign keys.

I need to copy the values of these tables into 3 tables called Regions, SubRegions and Countries when someone creates a new Game. In these 3 tables the values for the ongoing games are saved (GameId is added to differentiate the games).

Now, I need to update the relationships, since the primary keys obviously change.

Anyone knows a way to achieve this in an efficient manner?

My idea would involve cumbersome foreach loops, maybe someone else has an idea?

edit looks like my initial idea is the best way to go, 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. 2026-05-10T18:02:00+00:00Added an answer on May 10, 2026 at 6:02 pm

    Try this, it should create and interrelate all the new auto generated ID’s on submit.

    var defaultRegions = from r in DefaultRegions              select r;  IList<Region> rlist = new List<Region>(); foreach(var dr in defaultRegions) {     var r = new Region {         Name = dr.Name };      foreach(DefaultSubRegion dsr in dr.DefaultSubRegions) {         var sr = new SubRegion {             Name = dsr.Name };          foreach(DefaultCountries dc in dsf.DefaultCountries) {             var c = new Country {                 Name = dc.Name };              sr.Countries.Add(c);         }          r.SubRegions.Add(sr);    }     rlist.Add(r); }  DataContext dc = new DataContext(); dc.Regions.InsertAllOnSubmit(rlist); dc.Submit(); 

    This should work for you, and it is the easiest way I have found to copy data.

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

Sidebar

Related Questions

I have (after quite a bit of work) a web test that will upload
I'm building a simple game in an ASP.NET/VB.NET web app. The game has a
I have a game application that I will be running in a web browser
I am doing some work with Web.Routing, using it to have friendly urls and
I work on a web app that involves scheduling. A user can view his
I am doing some work on a web site that has a secure area
I am using an SVN repository for my web development work. I have a
The Problem When I try to get to my ASP.NET Web Page Razor pages
I've been developing a web game, with jquery doing some of the work. It
Im creating flash game that have the functionality to capture/record its gameplay that can

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.