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

  • Home
  • SEARCH
  • 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 956027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:28:45+00:00 2026-05-16T00:28:45+00:00

A database exists with two tables Data_t : DataID Primary Key that is Identity

  • 0

A database exists with two tables

  • Data_t : DataID Primary Key that is
    Identity 1,1. Also has another field
    ‘LEFT’ TINYINT
  • Data_Link_t : DataID PK and FK where
    DataID MUST exist in Data_t. Also has another field ‘RIGHT’ SMALLINT

Coming from a microsoft access environment into C# and sql server I’m looking for a good method of importing a record into this relationship.

The record contains information that belongs on both sides of this join (Possibly inserting/updating upwards 5000 records at once). Bonus to process the entire batch in some kind of LINQ list type command but even if this is done record by record the key goal is that BOTH sides of this record should be processed in the same step.

There are countless approaches and I’m looking at too many to determine which way I should go so I thought faster to ask the general public. Is LINQ an option for inserting/updating a big list like this with LINQ to SQL? Should I go record by record? What approach should I use to add a record to normalized tables that when joined create the full record?

  • 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-16T00:28:45+00:00Added an answer on May 16, 2026 at 12:28 am

    Sounds like a case where I’d write a small stored proc and call that from C# – e.g. as a function on my Linq-to-SQL data context object.

    Something like:

    CREATE PROCEDURE dbo.InsertData(@Left TINYINT, @Right SMALLINT)
    AS BEGIN
       DECLARE @DataID INT
    
       INSERT INTO dbo.Data_t(Left) VALUES(@Left)
    
       SELECT @DataID = SCOPE_IDENTITY();
    
       INSERT INTO dbo.Data_Link_T(DataID, Right) VALUES(@DataID, @Right)
    END
    

    If you import that into your data context, you could call this something like:

    using(YourDataContext ctx = new YourDataContext)
    {
       foreach(YourObjectType obj in YourListOfObjects)
       {
          ctx.InsertData(obj.Left, obj.Right)
       }
    }
    

    and let the stored proc handle all the rest (all the details, like determining and using the IDENTITY from the first table in the second one) for you.

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

Sidebar

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.