File tree Expand file tree Collapse file tree 3 files changed +88
-1
lines changed Expand file tree Collapse file tree 3 files changed +88
-1
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Data . Common ;
4+ using System . Globalization ;
5+ using System . Linq ;
6+ using System . Text ;
7+ using System . Threading . Tasks ;
8+
9+ namespace NHibernate . AdoNet
10+ {
11+ public class MySqlDbDataReader : DbDataReaderWrapper
12+ {
13+ public MySqlDbDataReader ( DbDataReader reader ) : base ( reader ) { }
14+
15+ // MySql driver has a bug that incorrectly uses the CurrentCulture to parse strings.
16+ public override float GetFloat ( int ordinal )
17+ {
18+ var value = DataReader [ ordinal ] ;
19+
20+ return value switch
21+ {
22+ string s => float . Parse ( s , CultureInfo . InvariantCulture ) ,
23+ _ => ( float ) value
24+ } ;
25+ }
26+
27+ public override double GetDouble ( int ordinal )
28+ {
29+ var value = DataReader [ ordinal ] ;
30+
31+ return value switch
32+ {
33+ string s => double . Parse ( s , CultureInfo . InvariantCulture ) ,
34+ _ => ( double ) value
35+ } ;
36+ }
37+
38+ public override decimal GetDecimal ( int ordinal )
39+ {
40+ var value = DataReader [ ordinal ] ;
41+
42+ return value switch
43+ {
44+ string s => decimal . Parse ( s , CultureInfo . InvariantCulture ) ,
45+ _ => ( decimal ) value
46+ } ;
47+ }
48+ }
49+ }
Original file line number Diff line number Diff line change 1+ //------------------------------------------------------------------------------
2+ // <auto-generated>
3+ // This code was generated by AsyncGenerator.
4+ //
5+ // Changes to this file may cause incorrect behavior and will be lost if
6+ // the code is regenerated.
7+ // </auto-generated>
8+ //------------------------------------------------------------------------------
9+
10+
11+ using System ;
12+ using System . Data . Common ;
13+ using NHibernate . AdoNet ;
14+
15+ namespace NHibernate . Driver
16+ {
17+ using System . Threading . Tasks ;
18+ using System . Threading ;
19+ public partial class MySqlDataDriver : ReflectionBasedDriver , IEmbeddedBatcherFactoryProvider
20+ {
21+
22+ public override async Task < DbDataReader > ExecuteReaderAsync ( DbCommand command , CancellationToken cancellationToken )
23+ {
24+ cancellationToken . ThrowIfCancellationRequested ( ) ;
25+ var reader = await ( command . ExecuteReaderAsync ( cancellationToken ) ) . ConfigureAwait ( false ) ;
26+
27+ return reader != null ? new MySqlDbDataReader ( reader ) : null ;
28+ }
29+ }
30+ }
Original file line number Diff line number Diff line change 11using System ;
2+ using System . Data . Common ;
23using NHibernate . AdoNet ;
34
45namespace NHibernate . Driver
@@ -17,7 +18,7 @@ namespace NHibernate.Driver
1718 /// for any updates and/or documentation regarding MySQL.
1819 /// </para>
1920 /// </remarks>
20- public class MySqlDataDriver : ReflectionBasedDriver , IEmbeddedBatcherFactoryProvider
21+ public partial class MySqlDataDriver : ReflectionBasedDriver , IEmbeddedBatcherFactoryProvider
2122 {
2223 /// <summary>
2324 /// Initializes a new instance of the <see cref="MySqlDataDriver"/> class.
@@ -79,6 +80,13 @@ public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplement
7980 /// <inheritdoc />
8081 public override DateTime MinDate => new DateTime ( 1000 , 1 , 1 ) ;
8182
83+ public override DbDataReader ExecuteReader ( DbCommand command )
84+ {
85+ var reader = command . ExecuteReader ( ) ;
86+
87+ return reader != null ? new MySqlDbDataReader ( reader ) : null ;
88+ }
89+
8290 System . Type IEmbeddedBatcherFactoryProvider . BatcherFactoryClass => typeof ( MySqlClientBatchingBatcherFactory ) ;
8391 }
8492}
You can’t perform that action at this time.
0 commit comments