Skip to content

Disposing QueryFactory dispose also my connection #650

Open

Description

@TinmarCyfar

When i dispose Queryfactory, il also dispose my connection (i use this connection in diffèrent other process)

Proposition : Delete this code ? (its not the role of sqlkata to dispose cnx)

image

Activity

  1. Cricle commented on Jan 1, 2023

    @Cricle

    I think it can't removed. Because the QueryFactory responsibilities include the management of database connection.(:

  2. oe-andreas-soroko commented on Feb 25, 2026

    @oe-andreas-soroko

    I ran into the same behavior as well.

    From my perspective, QueryFactory should not be responsible for opening/closing/disposing the underlying IDbConnection - especially when the connection is shared and managed outside of SqlKata (e.g., reused in further processing).

    At minimum, it would be great to have an opt-out / configuration flag to prevent disposal of the provided connection, similar in spirit to StreamReader(..., leaveOpen: true).

    That way:

    • SqlKata can still optionally manage a connection lifecycle for users who want it, but
    • callers who own the connection can retain full control and avoid unintended disposal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions