-
Notifications
You must be signed in to change notification settings - Fork 930
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-3530: The SqlServer 2008 driver does not support the DbDataReader.…
…GetChar method, wrap it in a SqlServerDbDataReader.
- Loading branch information
David Ellingsworth
authored and
David Ellingsworth
committed
Jun 11, 2024
1 parent
1c18cfe
commit cd6fa30
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.Common; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NHibernate.AdoNet | ||
{ | ||
public class SqlServerDbDataReader : DbDataReaderWrapper | ||
{ | ||
public SqlServerDbDataReader(DbDataReader reader) : base(reader) { } | ||
|
||
public override char GetChar(int ordinal) | ||
{ | ||
// SQL Server does not support GetChar | ||
var value = DataReader[ordinal]; | ||
|
||
return value switch | ||
{ | ||
string { Length: > 0 } s => s[0], | ||
_ => (char) value | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by AsyncGenerator. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
using System; | ||
using System.Data; | ||
using System.Data.Common; | ||
using NHibernate.Util; | ||
using NHibernate.AdoNet; | ||
|
||
namespace NHibernate.Driver | ||
{ | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
public partial class Sql2008ClientDriver : SqlClientDriver | ||
{ | ||
|
||
#if NETFX | ||
#else | ||
|
||
#endif | ||
|
||
public override async Task<DbDataReader> ExecuteReaderAsync(DbCommand command, CancellationToken cancellationToken) | ||
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
var reader = await (command.ExecuteReaderAsync(cancellationToken)).ConfigureAwait(false); | ||
|
||
return new SqlServerDbDataReader(reader); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters