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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:59:33+00:00 2026-06-15T18:59:33+00:00

I have the following situation: i need to create some temporary tables to optimize

  • 0

I have the following situation: i need to create some temporary tables to optimize a load problem the recently has ocurred. It seems that LINQ to SQL doesn’t work well with temporary table, unless they are mapped on the DBML. I, honestly, still don’t understand how scope works on LINQ to SQL. With that in mind i went to define every temporary table on the DBML.

But, as always, things can’t be that easy. I can’t define on compilation time (which is what linq needs) what name my temporary table will have, because it will be defined when an user logs on the system. To add more: i will have several of these dynamic temporary table, so there’s no way i can map it all to the DBML.

When i tried to create my temporary tables through executeCommand, select its results and cast it to strong type (TempTableDefinition). However, when i tried to insert values on this new created temporary table i got a SQLException saying ‘Invalid object name #NewTempTable’ (this was the same name i used to create the table).

It appears that i will have to use pure old plain ADO.NET to create every temporary table and map it’s properties to a strong typed object (i prefer this approach). I really wouldn’t like to mix ADO.NET with LINQ, since i just read that it’s a bad ideia. Plus, i prefer linq approach of strong type objects to the ADO.NET way.

Resume:
So, do you know or is it even possible to create dynamic temporary tables that linq to sql can work with? I can’t define it’s name on compilation time, only on execution time. Any tips will be appreciated.

  • 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-06-15T18:59:35+00:00Added an answer on June 15, 2026 at 6:59 pm

    The problem seems to be that L2S by default opens and closes the connection for each logical request. That kills your temp tables.

    Either open the connection manually (and close it, of course) or wrap everything in a TransactionScope which integrates with L2S and keeps the connection open.

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

Sidebar

Related Questions

I have a situation where I have to create tables dynamically. Depending on some
I have the following strange situation here I need some help with: I am
Did you ever have the following situation: you need to store information, but a
I'd need advice on following situation with Oracle/PostgreSQL: I have a db table with
I have following Situation, Server A sends some data (HTML form) to server B,
Ok, So I have the following situation. I originally had some code like this:
I have the following situation and I'm expecting some expert advise from SO folks.
I have a situation, where I need to create a new JavaScript object that
I have a situation where i need to create a left panel. My manager
So I have the following situation. I have a class DataTypes which has the

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.