@@ -454,7 +454,7 @@ type DesignTime private() =
454454
455455 ]
456456
457- static member GetCommandCtors ( cmdProvidedType : ProvidedTypeDefinition , designTimeConfig , designTimeConnectionString , ? factoryMethodName ) =
457+ static member internal GetCommandCtors ( cmdProvidedType : ProvidedTypeDefinition , designTimeConfig , ( designTimeConnectionString : DesignTimeConnectionString ), isHostedExecution , ? factoryMethodName ) =
458458 [
459459 let ctorImpl = typeof< `` ISqlCommand Implementation `` >. GetConstructor [| typeof< DesignTimeConfig>; typeof< Connection>; typeof< int> |]
460460
@@ -472,20 +472,26 @@ type DesignTime private() =
472472 then
473473 yield upcast ProvidedMethod( factoryMethodName.Value, parameters1, returnType = cmdProvidedType, IsStaticMethod = true , InvokeCode = body1)
474474
475- let parameters2 = [
476- ProvidedParameter( " connection" , typeof< SqlConnection>, optionalValue = null )
477- ProvidedParameter( " transaction" , typeof< SqlTransaction>, optionalValue = null )
478- ProvidedParameter( " commandTimeout" , typeof< int>, optionalValue = SqlCommand.DefaultTimeout)
479- ]
480-
475+ let parameters2 =
476+ [
477+ ProvidedParameter(
478+ " connection" ,
479+ typeof< SqlConnection>,
480+ ?optionalValue = if designTimeConnectionString.IsDefinedByLiteral then None else Some null
481+ )
482+ ProvidedParameter( " transaction" , typeof< SqlTransaction>, optionalValue = null )
483+ ProvidedParameter( " commandTimeout" , typeof< int>, optionalValue = SqlCommand.DefaultTimeout)
484+ ]
485+
486+ let connectionStringExpr = designTimeConnectionString.RunTimeValueExpr( isHostedExecution)
481487 let body2 ( args : _ list ) =
482488 let connArg =
483489 <@@
484490 if box (%% args.[ 1 ]: SqlTransaction) <> null
485491 then Connection.Choice3Of3 %% args.[ 1 ]
486492 elif box (%% args.[ 0 ]: SqlConnection) <> null
487493 then Connection.Choice2Of3 %% args.Head
488- else Connection.Choice1Of3( %% designTimeConnectionString )
494+ else Connection.Choice1Of3( %% connectionStringExpr )
489495 @@>
490496 Expr.NewObject( ctorImpl, [ designTimeConfig ; connArg; args.[ 2 ] ])
491497
0 commit comments