Skip to content

Commit

Permalink
Merge pull request #837 from Thorium/clear-cache
Browse files Browse the repository at this point in the history
Potential fix for #836
  • Loading branch information
Thorium authored Jan 15, 2025
2 parents 85082d8 + 77a2cfb commit 5ccba16
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 5ccba16

Please sign in to comment.