Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reuse TempTable created when also sending params into the execute #2063

Open
bdlee420 opened this issue Mar 29, 2024 · 2 comments
Open

Comments

@bdlee420
Copy link

If you add a param in the same call that creates the temp table then the temp table won't be accessible in future calls. This is a very strange behavior we came across today.

This works fine:

connection.Open();

await connection.ExecuteAsync(
@"create table #foo (val int not null);
insert #foo (val) values (123)");

await connection.ExecuteAsync(@"insert #foo (val) values (111)");
var vals = await connection.QueryAsync<int>(@"select * from #foo");

This fails. The error is that the temp table #foo doesn't exist.

connection.Open();
await connection.ExecuteAsync(
@"create table #foo (val int not null);
insert #foo (val) values (@InsertDate)", param: new { InsertDate = insertDate2 });

await connection.ExecuteAsync(@"insert #foo (val) values (111)");
var vals = await connection.QueryAsync<int>(@"select * from #foo");
@mgravell
Copy link
Member

Are you 100% the connection was open in the failing case? Not at a PC to try running it (will try to find time this weekend), but : that's the usual explanation for this happening.

@bdlee420
Copy link
Author

Yes 100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants