Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit c5a8812

Browse files
committed
Move seek of underlying IDbConnection/DbCommand to ToDbCommand() ext methods
1 parent 734b90f commit c5a8812

File tree

4 files changed

+4
-24
lines changed

4 files changed

+4
-24
lines changed

src/ServiceStack.OrmLite.MySql/MySqlDialectProvider.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,11 @@ public string GetColumnDefinition(FieldDefinition fieldDef)
228228

229229
protected MySqlConnection Unwrap(IDbConnection db)
230230
{
231-
var hasDb = db as IHasDbConnection;
232-
if (hasDb != null)
233-
return (MySqlConnection)hasDb.DbConnection;
234-
235231
return (MySqlConnection)db.ToDbConnection();
236232
}
237233

238234
protected MySqlCommand Unwrap(IDbCommand cmd)
239235
{
240-
var hasCmd = cmd as IHasDbCommand;
241-
if (hasCmd != null)
242-
return (MySqlCommand)hasCmd.DbCommand;
243-
244236
return (MySqlCommand)cmd.ToDbCommand();
245237
}
246238

src/ServiceStack.OrmLite.SqlServer/SqlServerOrmLiteDialectProvider.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,20 +465,12 @@ public override string GetLoadChildrenSubSelect<From>(ModelDefinition modelDef,
465465

466466
protected SqlConnection Unwrap(IDbConnection db)
467467
{
468-
var hasDb = db as IHasDbConnection;
469-
if (hasDb != null)
470-
return (SqlConnection)hasDb.DbConnection;
471-
472468
return (SqlConnection)db.ToDbConnection();
473469
}
474470

475471
protected SqlCommand Unwrap(IDbCommand cmd)
476472
{
477-
var hasCmd = cmd as IHasDbCommand;
478-
if (hasCmd != null)
479-
return (SqlCommand)hasCmd.DbCommand;
480-
481-
return (SqlCommand) cmd.ToDbCommand();
473+
return (SqlCommand)cmd.ToDbCommand();
482474
}
483475

484476
protected SqlDataReader Unwrap(IDataReader reader)

src/ServiceStack.OrmLite/OrmLiteCommand.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
using System.Data;
2+
using ServiceStack.Data;
23

34
namespace ServiceStack.OrmLite
45
{
5-
public interface IHasDbCommand
6-
{
7-
IDbCommand DbCommand { get; }
8-
}
9-
106
public class OrmLiteCommand : IDbCommand, IHasDbCommand
117
{
128
private OrmLiteConnection dbConn;

src/ServiceStack.OrmLite/OrmLiteConnectionFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ public static IDbConnection ToDbConnection(this IDbConnection db)
171171
{
172172
var hasDb = db as IHasDbConnection;
173173
return hasDb != null
174-
? hasDb.DbConnection
174+
? hasDb.DbConnection.ToDbConnection()
175175
: db;
176176
}
177177

178178
public static IDbCommand ToDbCommand(this IDbCommand dbCmd)
179179
{
180180
var hasDbCmd = dbCmd as IHasDbCommand;
181181
return hasDbCmd != null
182-
? hasDbCmd.DbCommand
182+
? hasDbCmd.DbCommand.ToDbCommand()
183183
: dbCmd;
184184
}
185185

0 commit comments

Comments
 (0)