Skip to content

Commit

Permalink
Potential fix for fsprojects#836
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorium committed Dec 8, 2024
1 parent 85082d8 commit 77a2cfb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/SQLProvider.DesignTime/SqlDesignTime.fs
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,26 @@ type public SqlTypeProvider(config: TypeProviderConfig) as this =
designTimeCommandsContainer.AddMember m
yield mOld :> MemberInfo

let clearCacheType = ProvidedTypeDefinition("ClearConnectionCache", Some typeof<obj>, isErased=true)
clearCacheType.AddMember(ProvidedConstructor([], empty))
clearCacheType.AddMembersDelayed(fun () ->

match con with
| Some con when con.State <> ConnectionState.Closed -> con.Close()
| _ -> ()

DesignTimeCache.cache.Clear()
GC.Collect()

[ ProvidedProperty("Done",typeof<unit>, getterCode = empty) :> MemberInfo ]
)
clearCacheType.AddXmlDocComputed(fun () -> "Close possible design-time database connection and clear connection cache")
let clearC = ProvidedProperty("ClearConnection", (clearCacheType :> Type), getterCode = empty)
clearC.AddXmlDocComputed(fun () -> "You can try to use this to refresh your database connection if you changed your database schema.")

designTimeCommandsContainer.AddMember clearC
serviceType.AddMember clearCacheType

serviceType.AddMember designTimeCommandsContainer
yield designTime :> MemberInfo

Expand Down

0 comments on commit 77a2cfb

Please sign in to comment.