The Wayback Machine - https://web.archive.org/web/20200903034700/https://github.com/dotnet/efcore/issues/21327
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding template methods for DbConnection calls #21327

Open
ajcvickers opened this issue Jun 18, 2020 · 4 comments
Open

Consider adding template methods for DbConnection calls #21327

ajcvickers opened this issue Jun 18, 2020 · 4 comments

Comments

@ajcvickers
Copy link
Member

@ajcvickers ajcvickers commented Jun 18, 2020

For #7283 I need to call a different overload of DbConnection.Open in the SQL Server provider. I'm adding a template method to allow this, but similar template methods could be useful in other providers. Tentative list of relevant methods based on what RelationalCommand calls:

  • BeginTransaction
  • Close
  • EnlistTransaction
  • State
  • Dispose

We could also consider doing this for other Db types where they are wrapped by EF.

ajcvickers added a commit that referenced this issue Jun 18, 2020
ajcvickers added a commit that referenced this issue Jun 18, 2020
…21328)

Fixes #7283

See also #21327
@ajcvickers ajcvickers added this to the Backlog milestone Jun 22, 2020
@ajcvickers ajcvickers self-assigned this Jun 22, 2020
@KaloyanIT
Copy link
Contributor

@KaloyanIT KaloyanIT commented Jul 28, 2020

Hi, I'm interested in contributing. In which providers should be added more template methods?

@ajcvickers
Copy link
Member Author

@ajcvickers ajcvickers commented Jul 29, 2020

These should be added to RelationalConnection as was done for OpenDbConnection in https://github.com/dotnet/efcore/pull/21328/files

@KaloyanIT
Copy link
Contributor

@KaloyanIT KaloyanIT commented Aug 2, 2020

I am not sure that I understand completely what should be done? Should these template methods be implemented in child classes of RelationalConnection?

@ajcvickers
Copy link
Member Author

@ajcvickers ajcvickers commented Aug 4, 2020

@KaloyanIT The PR above added a new method OpenDbConnection like this:

protected virtual void OpenDbConnection(bool errorsExpected)
            => DbConnection.Open();

It simply calls DbConnection.Open(). This is the kind of template method we're talking about here. These methods do not need to be overridden in any providers as part of this change. However, it makes it possible for providers to override these methods. That's what the objective is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.