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

Can Strongly Typed Convenience Methods be Added? #313

Closed
AdamDotNet opened this issue Aug 22, 2017 · 3 comments
Closed

Can Strongly Typed Convenience Methods be Added? #313

AdamDotNet opened this issue Aug 22, 2017 · 3 comments
Assignees
Milestone

Comments

@AdamDotNet
Copy link

@AdamDotNet AdamDotNet commented Aug 22, 2017

Hello.

Most/all ADO.Net providers I've used have returned their specific types instead of the System.Data.Common types. An example is PostgreSQL:CreateCommand().

Are you opposed to these convenience methods?

Taking a glance at 0.25.1 code, seems like, for example, it could be changed from:

protected override DbCommand CreateDbCommand() => new MySqlCommand(this, CurrentTransaction);

To:

/// <summary>
/// TODO: Documentation
/// </summary>
/// <returns></returns>
public new MySqlCommand CreateCommand() => new MySqlCommand(this, CurrentTransaction);

protected override DbCommand CreateDbCommand() => CreateCommand();

It would be good to apply these kinds of changes to all applicable DbConnection, DbCommand, etc. methods as well. This would make provider specific, and helpful, APIs become more visible and reduce friction from always having to cast from the common types. Example: #127, you can't see AddWithValue unless you cast.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Aug 25, 2017

Here are the "public new" methods in Connector/NET, which could be cloned for API compatibility (ticks by the ones that already exist):

MySqlCommand:
public new MySqlConnection Connection { get; set; }
public new MySqlParameterCollection Parameters { get; } ✔️
public new MySqlTransaction Transaction { get; set; }
public new MySqlParameter CreateParameter()
public new MySqlDataReader ExecuteReader()
public new MySqlDataReader ExecuteReader(CommandBehavior)

MySqlConnection:
public new MySqlTransaction BeginTransaction() ✔️
public new MySqlTransaction BeginTransaction(IsolationLevel)
public new MySqlCommand CreateCommand()

MySqlDataReader:
public new void Dispose() 😱

MySqlParameterCollection:
public new MySqlParameter this[int index] { get; set; } ✔️
public new MySqlParameter this[string name] { get; set; }

@bgrainger bgrainger added this to the 1.0 milestone Aug 25, 2017
@bgrainger bgrainger self-assigned this Aug 25, 2017
@AdamDotNet
Copy link
Author

@AdamDotNet AdamDotNet commented Aug 25, 2017

Awesome, thanks!

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Aug 25, 2017

Shipped in 0.26.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants