Skip to content

Commit 0d344d2

Browse files
jrochabgrainger
authored andcommitted
Support for Enterprise Library (#567)
Added ICloneable to MySqlParameter so it can be used by Enterprise Library. Added an implementation of CopyTo on MySqlParameterCollection.
1 parent 2273ca5 commit 0d344d2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/MySqlConnector/MySql.Data.MySqlClient/MySqlParameter.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010

1111
namespace MySql.Data.MySqlClient
1212
{
13+
14+
#if !NETSTANDARD1_3
15+
public sealed class MySqlParameter : DbParameter, IDbDataParameter, ICloneable
16+
#else
1317
public sealed class MySqlParameter : DbParameter, IDbDataParameter
18+
#endif
1419
{
1520
public MySqlParameter()
1621
{
@@ -612,6 +617,13 @@ private static void WriteTime(ByteBufferWriter writer, TimeSpan timeSpan)
612617
}
613618
}
614619

620+
#if !NETSTANDARD1_3
621+
public object Clone()
622+
{
623+
return new MySqlParameter(ParameterName, MySqlDbType, Size, Direction, IsNullable, Precision, Scale, SourceColumn, SourceVersion, Value);
624+
}
625+
#endif
626+
615627
static readonly byte[] s_nullBytes = { 0x4E, 0x55, 0x4C, 0x4C }; // NULL
616628
static readonly byte[] s_trueBytes = { 0x74, 0x72, 0x75, 0x65 }; // true
617629
static readonly byte[] s_falseBytes = { 0x66, 0x61, 0x6C, 0x73, 0x65 }; // false

src/MySqlConnector/MySql.Data.MySqlClient/MySqlParameterCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public MySqlParameter AddWithValue(string parameterName, object value)
6363

6464
public override bool Contains(string value) => IndexOf(value) != -1;
6565

66-
public override void CopyTo(Array array, int index) => throw new NotSupportedException();
66+
public override void CopyTo(Array array, int index) => ((ICollection) m_parameters).CopyTo( array, index);
6767

6868
public override void Clear()
6969
{

0 commit comments

Comments
 (0)