Faithlife / FaithlifeData

Helpers for querying ADO.NET-compatible databases.
https://faithlife.github.io/FaithlifeData/
MIT License
6 stars 4 forks source link

Support closing lazy-open connections temporarily #45

Closed ejball closed 3 years ago

ejball commented 3 years ago

Normally the connection is closed when the disposable returned by OpenConnection is disposed, or, in the case of AutoOpen, when the connector itself is disposed. CloseConnection(Async) would allow the connection to be closed earlier than normal.

In the case of AutoOpen, we should reopen the connection immediately, which makes this not very useful, unless LazyOpen is also in use, in which case it won't open until (and unless) it is used again. This is probably the best use case of the new method, but it might also make the code confusing when the connection is used again later after being explicitly closed and without being explicitly opened. Maybe there's a better name?

There's already a private implementation of CloseConnection(Async), which is fine, except we should allow an already-closed connection to be closed, and we need to respect AutoOpen and LazyOpen.

ejball commented 3 years ago

Maybe there's a better name?

The more I think about it, the ability to temporarily close an AutoOpen/LazyOpen connection seems like the only interesting use case, in which case maybe RefreshConnection(Async) would be defined as closing and (lazy) opening the connection.

bgrainger commented 3 years ago

ReleaseConnection?

"Refresh" to me implies ensuring it's connected, which is the opposite of the intent (as I understand it).