Skip to content

Commit

Permalink
feat(nuget): update core package
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry Perret committed Jan 13, 2021
1 parent 76220ab commit aac816a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
35 changes: 20 additions & 15 deletions Vp.FSharp.Sql.SqlServer/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,31 @@ type SqlServerDbValue =
type SqlServerCommandDefinition =
CommandDefinition<
SqlConnection,
SqlTransaction,
SqlCommand,
SqlParameter,
SqlDataReader,
SqlTransaction,
SqlServerDbValue>

type SqlServerGlobalConf =
SqlGlobalConf<
type SqlServerConfiguration =
SqlConfigurationCache<
SqlConnection,
SqlCommand>

type SqlServerDeps =
SqlDeps<
type SqlServerDependencies =
SqlDependencies<
SqlConnection,
SqlTransaction,
SqlCommand,
SqlParameter,
SqlDataReader,
SqlTransaction,
SqlServerDbValue>

[<RequireQualifiedAccess>]
module SqlServerNullDbValue =
let ifNone toDbValue = NullDbValue.ifNone toDbValue SqlServerDbValue.Null
let ifError toDbValue = NullDbValue.ifError toDbValue (fun _ -> SqlServerDbValue.Null)

[<RequireQualifiedAccess>]
module SqlServerCommand =

Expand Down Expand Up @@ -189,7 +194,7 @@ module SqlServerCommand =
parameter.SqlDbType <- SqlDbType.Variant
parameter

let private deps: SqlServerDeps =
let private deps: SqlServerDependencies =
{ CreateCommand = fun connection -> connection.CreateCommand()
ExecuteReaderAsync = fun command -> command.ExecuteReaderAsync
DbValueToParameter = dbValueToParameter }
Expand Down Expand Up @@ -237,44 +242,44 @@ module SqlServerCommand =
/// Return the sets of rows as an AsyncSeq accordingly to the command definition.
let queryAsyncSeq connection read (commandDefinition: SqlServerCommandDefinition) =
SqlCommand.queryAsyncSeq
connection deps (SqlServerGlobalConf.Snapshot) read commandDefinition
connection deps (SqlServerConfiguration.Snapshot) read commandDefinition

/// Return the sets of rows as a list accordingly to the command definition.
let queryList connection read (commandDefinition: SqlServerCommandDefinition) =
SqlCommand.queryList
connection deps (SqlServerGlobalConf.Snapshot) read commandDefinition
connection deps (SqlServerConfiguration.Snapshot) read commandDefinition

/// Return the first set of rows as a list accordingly to the command definition.
let querySetList connection read (commandDefinition: SqlServerCommandDefinition) =
SqlCommand.querySetList
connection deps (SqlServerGlobalConf.Snapshot) read commandDefinition
connection deps (SqlServerConfiguration.Snapshot) read commandDefinition

/// Return the 2 first sets of rows as a tuple of 2 lists accordingly to the command definition.
let querySetList2 connection read1 read2 (commandDefinition: SqlServerCommandDefinition) =
SqlCommand.querySetList2
connection deps (SqlServerGlobalConf.Snapshot) read1 read2 commandDefinition
connection deps (SqlServerConfiguration.Snapshot) read1 read2 commandDefinition

/// Return the 3 first sets of rows as a tuple of 3 lists accordingly to the command definition.
let querySetList3 connection read1 read2 read3 (commandDefinition: SqlServerCommandDefinition) =
SqlCommand.querySetList3
connection deps (SqlServerGlobalConf.Snapshot) read1 read2 read3 commandDefinition
connection deps (SqlServerConfiguration.Snapshot) read1 read2 read3 commandDefinition

/// Execute the command accordingly to its definition and,
/// - return the first cell value, if it is available and of the given type.
/// - throw an exception, otherwise.
let executeScalar<'Scalar> connection (commandDefinition: SqlServerCommandDefinition) =
SqlCommand.executeScalar<'Scalar, _, _, _, _, _, _, _, _, _>
connection deps (SqlServerGlobalConf.Snapshot) commandDefinition
connection deps (SqlServerConfiguration.Snapshot) commandDefinition

/// Execute the command accordingly to its definition and,
/// - return Some, if the first cell is available and of the given type.
/// - return None, if first cell is DbNull.
/// - throw an exception, otherwise.
let executeScalarOrNone<'Scalar> connection (commandDefinition: SqlServerCommandDefinition) =
SqlCommand.executeScalarOrNone<'Scalar, _, _, _, _, _, _, _, _, _>
connection deps (SqlServerGlobalConf.Snapshot) commandDefinition
connection deps (SqlServerConfiguration.Snapshot) commandDefinition

/// Execute the command accordingly to its definition and, return the number of rows affected.
let executeNonQuery connection (commandDefinition: SqlServerCommandDefinition) =
SqlCommand.executeNonQuery
connection deps (SqlServerGlobalConf.Snapshot) commandDefinition
connection deps (SqlServerConfiguration.Snapshot) commandDefinition
2 changes: 1 addition & 1 deletion Vp.FSharp.Sql.SqlServer/Vp.FSharp.Sql.SqlServer.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.0" />
<PackageReference Include="Vp.FSharp.Sql" Version="1.0.31" />
<PackageReference Include="Vp.FSharp.Sql" Version="1.0.32" />
</ItemGroup>

</Project>

0 comments on commit aac816a

Please sign in to comment.