Skip to content

Commit ef70686

Browse files
fix: make connection optional when literal connection string is configured
When SqlCommandProvider or SqlProgrammabilityProvider is configured with a literal connection string at design time, the connection parameter in the generated constructor/factory method was incorrectly required. This meant users had to pass an open SqlConnection even when a literal connection string was available. The fix makes the connection parameter always optional (defaulting to null). The existing body2 logic already handles null by falling back to the design-time connection string expression, so no further changes are needed. Users can now call: AdventureWorks.CreateCommand<"SELECT ...">().Execute() instead of having to first open a SqlConnection. Closes #245 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f8a4561 commit ef70686

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/SqlClient.DesignTime/DesignTime.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ type DesignTime private() =
652652
ProvidedParameter(
653653
"connection",
654654
typeof<SqlConnection>,
655-
?optionalValue = if designTimeConnectionString.IsDefinedByLiteral then None else Some null
655+
?optionalValue = Some null
656656
)
657657
ProvidedParameter("transaction", typeof<SqlTransaction>, optionalValue = null)
658658
ProvidedParameter("commandTimeout", typeof<int>, optionalValue = SqlCommand.DefaultTimeout)

0 commit comments

Comments
 (0)