File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
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 . Linq ;
5+ using System . Text ;
6+ using System . Threading . Tasks ;
7+
8+ namespace NHibernate . AdoNet
9+ {
10+ /// <summary>
11+ /// Many database drivers lack support for DbDataReader.GetChar and throw a
12+ /// NotSupportedException. This reader provides an implementation on top of
13+ /// the indexer method for defficient drivers.
14+ /// </summary>
15+ public class NoCharDbDataReader : DbDataReaderWrapper
16+ {
17+ public NoCharDbDataReader ( DbDataReader reader ) : base ( reader ) { }
18+
19+ public override char GetChar ( int ordinal )
20+ {
21+ // The underlying DataReader does not support the GetChar method.
22+ // Use the indexer to obtain the value and convert it to a char if necessary.
23+ var value = DataReader [ ordinal ] ;
24+
25+ return value switch
26+ {
27+ string { Length : > 0 } s => s [ 0 ] ,
28+ _ => ( char ) value
29+ } ;
30+ }
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments