Questions tagged [idbconnection]
26 questions
34
votes
4 answers
Proper way of using BeginTransaction with Dapper.IDbConnection
Which is the proper way of using BeginTransaction() with IDbConnection in Dapper ?
I have created a method in which i have to use BeginTransaction(). Here is the code.
using (IDbConnection cn = DBConnection)
{
var oTransaction =…

Krishnraj Rana
- 6,516
- 2
- 29
- 36
16
votes
3 answers
What does "opening a connection" actually mean?
I was trying to explain to someone why database connections implement IDisposable, when I realized I don't really know what "opening a connection" actually mean.
So my question is - What does c# practically do when it opens a connection?
Thank…

Oren A
- 5,870
- 6
- 43
- 64
10
votes
1 answer
.Net Core Dependency Injection IdbConnection
I have a .NET MVC app that uses autofac for Dependency Injection.
When the app starts the following code registers IDbConnection
var connectionString = …

Christoph Adamakis
- 865
- 2
- 9
- 26
8
votes
2 answers
IDbConnection lifecycle management with persistent HTTP connections
I have a problem managing the lifetime of open database connections with StructureMap scoped to HttpContext when there are persistent HTTP connections in my ASP.NET MVC application, like SignalR hubs.
My DI container, StructureMap, injects an open…

Petrus Theron
- 27,855
- 36
- 153
- 287
4
votes
1 answer
Dapper. IDbConnection and IDbTransaction
How should I use an IDbConnection and an IDbTransaction with Dapper?
At the moment I am using only a IDbConnection. Something as follows:
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Execute(@"insert…

Miguel Moura
- 36,732
- 85
- 259
- 481
4
votes
1 answer
Injecting connection strings vs IDbConnection
What are the trade-offs for injecting connection strings vs. an instance of IDbConnection?
I use StructureMap to inject various services into my ASP.NET MVC application, most of which require database access for LINQ-to-SQL queries. Injecting an…

Petrus Theron
- 27,855
- 36
- 153
- 287
3
votes
1 answer
C# MySql Connector/Net issues
Currently running Mono. I loaded MySQL and installed connector/net in my gac folder located in /usr/lib/mono/gac. The problem is that everytime I try to run it using a simple connection test, I get the following error:
**…

zeboidlund
- 9,731
- 31
- 118
- 180
3
votes
1 answer
Dapper Hangs at Execute
I have an
- IDbConnection
- sql = @"UPDATE tablename SET json = :json, lastupdate = SYSDATE WHERE id = :id"
var param = new DynamicParameters();
param.Add(":json", json, DbType.AnsiString);
param.Add(":id", currentTemplate.Id);
if (connection ==…

JuanPablo
- 813
- 7
- 11
3
votes
2 answers
IDbConnection and using blocks in c#
I understand that wrapping an IDbConnection object in a using block ensures that Dispose will get called and the resources it is using will get freed. That being said do I also need to wrap IDbCommand and IDataReader in using blocks as well, or is…

jfin3204
- 699
- 6
- 18
3
votes
3 answers
Unmanaged Resources, IDisposable and Custom Types
yet another topic on the subject as I got tired of reading countless topics to find an answer to my questions :)
Lets say we have the following class:
public class MyClass
{
private const string conString = "connection string";
private int…

Pantelis
- 2,060
- 3
- 25
- 40
2
votes
1 answer
Issues faced during ServiceStack Ugrade from 3.9.71 to 5.9.2
ServiceStack Old Version: 3.9.71
ServiceStack New version: 5.9.2
.Net Framework: 4.6.1
We are facing quite a few issues while trying to upgrade ServiceStack. Could someone please help.
The predominant issue is as below:
CS0012 The type…

Poulomi Sengupta
- 21
- 1
2
votes
1 answer
Register abstract class with autofac
I just run this code in a quickly made console app with autofac assembly added:
builder.RegisterType().As().WithParameter("connectionString", connectionString);
There was no exception although DbConnection is of…

Elisabeth
- 20,496
- 52
- 200
- 321
2
votes
2 answers
IDBCommand Parameters for multi-line insert
I want to create a multi-line insert statement along these lines:
insert into foo (
value1,
value2,
value3
) values
( "1", "2", "3"),
( "4", "5", "6"),
( "7", "8", "9");
where the number of rows to be inserted is variable. Is there a…

Jeremy Holovacs
- 22,480
- 33
- 117
- 254
1
vote
1 answer
Is there a generic way of passing a DbType as a parameter
I need to execute this parameterized query, or an equivalent:
ALTER TABLE tableName ADD COLUMN ? ?
with the parameters as the name of the new column, and the data type.
For example, if I pass in 'Name' DbType.Double, then it would resolve to:
ALTER…

Flynn1179
- 11,925
- 6
- 38
- 74
1
vote
1 answer
Service's Db is null in ServiceStack v4
I've used the free version of ServiceStack for a couple of years now and have recently purchased v4 for use in a project.
I have read through the release notes and associated blogs but cannot find any guidance on the issue I am having...
Having made…

Drammy
- 940
- 12
- 30