Skip to content

Commit ed24def

Browse files
SqlDataRecord reflection resolution is different depending the SqlClient library, tests passing now.
1 parent ce3a2b2 commit ed24def

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/SqlClient.DesignTime/DesignTime.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ type DesignTime private() =
611611
//record.SetValues(values) |> ignore
612612

613613
//done via reflection because not implemented on Mono
614-
let sqlDataRecordType = typeof<SqlCommand>.Assembly.GetType("Microsoft.SqlServer.Server.SqlDataRecord", throwOnError = true)
614+
let sqlDataRecordType = TypeResolution.sqlDataRecordType
615615
let record = Activator.CreateInstance(sqlDataRecordType, args = [| %%Expr.Coerce(Expr.NewArray(typeof<SqlMetaData>, sqlMetas), typeof<obj>) |])
616616
sqlDataRecordType.GetMethod("SetValues").Invoke(record, [| values |]) |> ignore
617617

src/SqlClient/ISqlCommand.fs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ module internal TypeResolution =
6161
Type.GetType(stripped, throwOnError = true)
6262
| t -> t
6363

64+
let sqlDataRecordType =
65+
typeof<SqlCommand>
66+
.Assembly
67+
#if SYSTEM_DATA_SQLCLIENT
68+
.GetType("Microsoft.SqlServer.Server.SqlDataRecord", throwOnError = true)
69+
#endif
70+
#if MICROSOFT_DATA_SQLCLIENT
71+
.GetType("Microsoft.Data.SqlClient.Server.SqlDataRecord", throwOnError = true)
72+
#endif
73+
6474
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>]
6575
type RowMapping = obj[] -> obj
6676

@@ -264,7 +274,7 @@ type ``ISqlCommand Implementation``(cfg: DesignTimeConfig, connection: Connectio
264274

265275
//done via reflection because not implemented on Mono
266276

267-
let sqlDataRecordType = typeof<SqlCommand>.Assembly.GetType("Microsoft.SqlServer.Server.SqlDataRecord", throwOnError = true)
277+
let sqlDataRecordType = TypeResolution.sqlDataRecordType
268278
let records = typeof<Linq.Enumerable>.GetMethod("Cast").MakeGenericMethod(sqlDataRecordType).Invoke(null, [| value |])
269279
let hasAny =
270280
let anyMeth =

0 commit comments

Comments
 (0)