Skip to content

Commit b08e2b9

Browse files
authored
Merge pull request #241 from hazzik/NH-3431
NH-3431 - Replace usage of System.Data classes to System.Data.Common
2 parents 252d3f3 + f209c2b commit b08e2b9

File tree

268 files changed

+1584
-1611
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+1584
-1611
lines changed

src/NHibernate.DomainModel/DoubleStringType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Data;
2+
using System.Data.Common;
33

44
using NHibernate.Engine;
55
using NHibernate.Type;
@@ -49,7 +49,7 @@ public bool IsMutable
4949
get { return true; }
5050
}
5151

52-
public Object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, Object owner)
52+
public Object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, Object owner)
5353
{
5454
string first = (string) NHibernateUtil.String.NullSafeGet(rs, names[0], session, owner);
5555
string second = (string) NHibernateUtil.String.NullSafeGet(rs, names[1], session, owner);
@@ -58,7 +58,7 @@ public Object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor se
5858
}
5959

6060

61-
public void NullSafeSet(IDbCommand st, Object value, int index, bool[] settable, ISessionImplementor session)
61+
public void NullSafeSet(DbCommand st, Object value, int index, bool[] settable, ISessionImplementor session)
6262
{
6363
string[] strings = (value == null) ? new string[2] : (string[]) value;
6464

src/NHibernate.DomainModel/MultiplicityType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Data;
2+
using System.Data.Common;
33
using System.Linq;
44
using NHibernate.Engine;
55
using NHibernate.Type;
@@ -74,7 +74,7 @@ public int GetHashCode(object x)
7474
}
7575
}
7676

77-
public object NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
77+
public object NullSafeGet(DbDataReader rs, String[] names, ISessionImplementor session, Object owner)
7878
{
7979
int c = (int) NHibernateUtil.Int32.NullSafeGet(rs, names[0], session, owner);
8080
GlarchProxy g = (GlarchProxy) NHibernateUtil.Entity(typeof(Glarch)).NullSafeGet(rs, names[1], session, owner);
@@ -84,7 +84,7 @@ public object NullSafeGet(IDataReader rs, String[] names, ISessionImplementor se
8484
return m;
8585
}
8686

87-
public void NullSafeSet(IDbCommand st, Object value, int index, bool[] settable, ISessionImplementor session)
87+
public void NullSafeSet(DbCommand st, Object value, int index, bool[] settable, ISessionImplementor session)
8888
{
8989
Multiplicity o = (Multiplicity) value;
9090
GlarchProxy g;

src/NHibernate.DomainModel/NHSpecific/NullInt32UserType.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Data;
2+
using System.Data.Common;
33

44
using NHibernate.SqlTypes;
55
using NHibernate.Type;
@@ -46,11 +46,11 @@ public object DeepCopy(object value)
4646
return value;
4747
}
4848

49-
public void NullSafeSet(IDbCommand cmd, object value, int index)
49+
public void NullSafeSet(DbCommand cmd, object value, int index)
5050
{
5151
if (value.Equals(0))
5252
{
53-
((IDbDataParameter) cmd.Parameters[index]).Value = DBNull.Value;
53+
cmd.Parameters[index].Value = DBNull.Value;
5454
}
5555
else
5656
{
@@ -63,7 +63,7 @@ public System.Type ReturnedType
6363
get { return typeof(Int32); }
6464
}
6565

66-
public object NullSafeGet(IDataReader rs, string[] names, object owner)
66+
public object NullSafeGet(DbDataReader rs, string[] names, object owner)
6767
{
6868
return _int32Type.NullSafeGet(rs, names);
6969
}

src/NHibernate.DomainModel/NHSpecific/NullableInt32Type.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Data;
2+
using System.Data.Common;
33

44
using NHibernate.SqlTypes;
55
using NHibernate.Type;
@@ -26,14 +26,14 @@ public override System.Type ReturnedClass
2626
get { return typeof(NullableInt32); }
2727
}
2828

29-
public override object Get(IDataReader rs, int index)
29+
public override object Get(DbDataReader rs, int index)
3030
{
3131
return new NullableInt32(Convert.ToInt32(rs[index]));
3232
}
3333

34-
public override void Set(IDbCommand cmd, object value, int index)
34+
public override void Set(DbCommand cmd, object value, int index)
3535
{
36-
IDataParameter parameter = (IDataParameter) cmd.Parameters[index];
36+
var parameter = cmd.Parameters[index];
3737
NullableInt32 nullableValue = (NullableInt32) value;
3838

3939
if (nullableValue.HasValue)

src/NHibernate.DomainModel/NHSpecific/NullableTypesType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Data;
2+
using System.Data.Common;
33

44
using NHibernate.SqlTypes;
55
using NHibernate.Type;
@@ -17,7 +17,7 @@ public NullableTypesType(SqlType type) : base(type)
1717
{
1818
}
1919

20-
public override object NullSafeGet(IDataReader rs, string name)
20+
public override object NullSafeGet(DbDataReader rs, string name)
2121
{
2222
object value = base.NullSafeGet(rs, name);
2323
if (value == null)
@@ -30,7 +30,7 @@ public override object NullSafeGet(IDataReader rs, string name)
3030
}
3131
}
3232

33-
public override object Get(IDataReader rs, string name)
33+
public override object Get(DbDataReader rs, string name)
3434
{
3535
return Get(rs, rs.GetOrdinal(name));
3636
}

src/NHibernate.DomainModel/Northwind/Entities/User.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Data;
2+
using System.Data.Common;
33
using NHibernate.Type;
44

55
namespace NHibernate.DomainModel.Northwind.Entities
@@ -71,15 +71,15 @@ public class EnumStoredAsStringType : EnumStringType
7171
public EnumStoredAsStringType()
7272
: base(typeof(EnumStoredAsString), 12) { }
7373

74-
public override void Set(IDbCommand cmd, object value, int index)
74+
public override void Set(DbCommand cmd, object value, int index)
7575
{
7676
if (value is EnumStoredAsString && (EnumStoredAsString)value == EnumStoredAsString.Unspecified)
7777
base.Set(cmd, null, index);
7878
else
7979
base.Set(cmd, value, index);
8080
}
8181

82-
public override object Get(IDataReader rs, int index)
82+
public override object Get(DbDataReader rs, int index)
8383
{
8484
object obj = base.Get(rs, index);
8585
if (obj == null) return EnumStoredAsString.Unspecified;

src/NHibernate.Test/Cascade/RefreshFixture.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Data;
4+
using System.Data.Common;
45
using NUnit.Framework;
56

67
namespace NHibernate.Test.Cascade
@@ -51,8 +52,8 @@ public void RefreshCascade()
5152

5253
private void UpdateStatuses(ISession session)
5354
{
54-
IDbConnection conn = session.Connection;
55-
IDbCommand cmd = conn.CreateCommand();
55+
var conn = session.Connection;
56+
var cmd = conn.CreateCommand();
5657
cmd.CommandText = "UPDATE T_JOB SET JOB_STATUS = 1";
5758
cmd.CommandType = CommandType.Text;
5859
session.Transaction.Enlist(cmd);

src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Data;
12
using NHibernate.AdoNet;
23
using NHibernate.Bytecode;
34
using NHibernate.Cache;
@@ -8,7 +9,6 @@
89
using NHibernate.Linq.Functions;
910
using NHibernate.Type;
1011
using NUnit.Framework;
11-
using System.Data;
1212
using NHibernate.Exceptions;
1313

1414
namespace NHibernate.Test.CfgTest.Loquacious

src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Data;
3+
using System.Data.Common;
44
using NHibernate.Connection;
55
using NUnit.Framework;
66
using Environment=NHibernate.Cfg.Environment;
@@ -56,10 +56,10 @@ public string PublicConnectionString
5656
}
5757

5858
/// <summary>
59-
/// Get an open <see cref="IDbConnection"/>.
59+
/// Get an open <see cref="DbConnection"/>.
6060
/// </summary>
61-
/// <returns>An open <see cref="IDbConnection"/>.</returns>
62-
public override IDbConnection GetConnection()
61+
/// <returns>An open <see cref="DbConnection"/>.</returns>
62+
public override DbConnection GetConnection()
6363
{
6464
throw new NotImplementedException();
6565
}

src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4-
using System.Data;
4+
using System.Data.Common;
55
using NHibernate.Cfg;
66
using NHibernate.Util;
77
using NUnit.Framework;
@@ -176,7 +176,7 @@ public void SuppliedConnection()
176176
{
177177
Prepare();
178178

179-
IDbConnection originalConnection = sessions.ConnectionProvider.GetConnection();
179+
DbConnection originalConnection = sessions.ConnectionProvider.GetConnection();
180180
ISession session = sessions.OpenSession(originalConnection);
181181

182182
Silly silly = new Silly("silly");
@@ -203,7 +203,7 @@ public void SuppliedConnection()
203203
// Prepare();
204204
// ISession s = GetSessionUnderTest();
205205

206-
// IDbConnection conn = s.Connection;
206+
// DbConnection conn = s.Connection;
207207
// Assert.IsTrue(((SessionImpl) s).ConnectionManager.HasBorrowedConnection);
208208
// conn.Close();
209209
// Assert.IsFalse(((SessionImpl) s).ConnectionManager.HasBorrowedConnection);

src/NHibernate.Test/DateTimeOffsetUserType.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Data;
3+
using System.Data.Common;
34
using NHibernate.SqlTypes;
45
using NHibernate.UserTypes;
56

@@ -28,7 +29,7 @@ public SqlType[] SqlTypes
2829
get { return new[] { new SqlType(DbType.DateTime) }; }
2930
}
3031

31-
public object NullSafeGet(IDataReader dr, string[] names, object owner)
32+
public object NullSafeGet(DbDataReader dr, string[] names, object owner)
3233
{
3334
var name = names[0];
3435
int index = dr.GetOrdinal(name);
@@ -61,7 +62,7 @@ public object NullSafeGet(IDataReader dr, string[] names, object owner)
6162
}
6263
}
6364

64-
public void NullSafeSet(IDbCommand cmd, object value, int index)
65+
public void NullSafeSet(DbCommand cmd, object value, int index)
6566
{
6667
if (value == null)
6768
{
@@ -72,8 +73,7 @@ public void NullSafeSet(IDbCommand cmd, object value, int index)
7273
DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
7374
DateTime paramVal = dateTimeOffset.ToOffset(Offset).DateTime;
7475

75-
IDataParameter parameter = (IDataParameter)cmd.Parameters[index];
76-
parameter.Value = paramVal;
76+
cmd.Parameters[index].Value = paramVal;
7777
}
7878
}
7979

src/NHibernate.Test/DebugConnectionProvider.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Data;
4+
using System.Data.Common;
45
using System.Linq;
56
using NHibernate.Connection;
67

@@ -12,13 +13,13 @@ namespace NHibernate.Test
1213
/// </summary>
1314
public class DebugConnectionProvider : DriverConnectionProvider
1415
{
15-
private ConcurrentDictionary<IDbConnection, byte> connections = new ConcurrentDictionary<IDbConnection, byte>();
16+
private ConcurrentDictionary<DbConnection, byte> connections = new ConcurrentDictionary<DbConnection, byte>();
1617

17-
public override IDbConnection GetConnection()
18+
public override DbConnection GetConnection()
1819
{
1920
try
2021
{
21-
IDbConnection connection = base.GetConnection();
22+
var connection = base.GetConnection();
2223
connections.TryAdd(connection, 0);
2324
return connection;
2425
}
@@ -28,7 +29,7 @@ public override IDbConnection GetConnection()
2829
}
2930
}
3031

31-
public override void CloseConnection(IDbConnection conn)
32+
public override void CloseConnection(DbConnection conn)
3233
{
3334
base.CloseConnection(conn);
3435
byte _;
@@ -40,8 +41,8 @@ public bool HasOpenConnections
4041
get
4142
{
4243
// Disposing of an ISession does not call CloseConnection (should it???)
43-
// so a Diposed of ISession will leave an IDbConnection in the list but
44-
// the IDbConnection will be closed (atleast with MsSql it works this way).
44+
// so a Diposed of ISession will leave an DbConnection in the list but
45+
// the DbConnection will be closed (atleast with MsSql it works this way).
4546
return connections.Keys.Any(conn => conn.State != ConnectionState.Closed);
4647
}
4748
}

src/NHibernate.Test/DialectTest/DialectFixture.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Data;
4+
using System.Data.Common;
45
using NHibernate.Dialect;
56
using NHibernate.Driver;
67
using NHibernate.Engine;
@@ -159,18 +160,16 @@ public void CurrentTimestampSelection()
159160
sessions.ConnectionProvider.Configure(conf.Properties);
160161
IDriver driver = sessions.ConnectionProvider.Driver;
161162

162-
using (IDbConnection connection = sessions.ConnectionProvider.GetConnection())
163+
using (var connection = sessions.ConnectionProvider.GetConnection())
163164
{
164-
IDbCommand statement = driver.GenerateCommand(CommandType.Text, new SqlString(dialect.CurrentTimestampSelectString),
165-
new SqlType[0]);
165+
var statement = driver.GenerateCommand(CommandType.Text, new SqlString(dialect.CurrentTimestampSelectString), new SqlType[0]);
166166
statement.Connection = connection;
167-
using (IDataReader reader = statement.ExecuteReader())
167+
using (var reader = statement.ExecuteReader())
168168
{
169169
Assert.That(reader.Read(), "should return one record");
170170
Assert.That(reader[0], Is.InstanceOf<DateTime>());
171171
}
172172
}
173173
}
174-
175174
}
176175
}

0 commit comments

Comments
 (0)