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

Implement more constructors to MySqlParameter #402

Closed
Mimetis opened this issue Nov 24, 2017 · 2 comments
Closed

Implement more constructors to MySqlParameter #402

Mimetis opened this issue Nov 24, 2017 · 2 comments
Assignees

Comments

@Mimetis
Copy link

@Mimetis Mimetis commented Nov 24, 2017

Hi !
Actually with DbParameter implémentations lik SqlParameter or SqliteParameter (and so on...) we have mulitples constructors available.
For instance, SqlClient assembly have such constructors :

public SqlParameter();
public SqlParameter(string parameterName, SqlDbType dbType);
public SqlParameter(string parameterName, object value);
public SqlParameter(string parameterName, SqlDbType dbType, int size);
public SqlParameter(string parameterName, SqlDbType dbType, int size, string sourceColumn);
public SqlParameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, bool sourceColumnNullMapping, object value, string xmlSchemaCollectionDatabase, string xmlSchemaCollectionOwningSchema, string xmlSchemaCollectionName);

Two main reasons to implements more constuctors in MySqlParameter

Just because it's obvious :)

In MySqlConnector we only have:

public MySqlParameter();
public MySqlParameter(string name, object objValue);

In most of the cases, it's enough :)

But (in my case for instance) I have to prepare all my parameters and set the values after.
So I have to deal with the parameterless constructor, actually:

MySqlParameter sqlParameter = new MySqlParameter();
sqlParameter.ParameterName = "sync_scope_id";
sqlParameter.MySqlDbType = MySqlDbType.Guid;
sqlParameter.Size = 36;

Compatibility whith official MySQL connector

Actually all my code is written like this:

MySqlParameter sqlParameter3 = new MySqlParameter("create_timestamp", MySqlDbType.Int64);

This code was working with the official MySQL provider, since the parameter constructor public MySqlParameter(string parameterName, MySqlDbType dbType); is available.
In MySqlConnector the MySqlDbType variable becomes... the value !

I think it would be great to have ... sort of equivalence or compatibility with the MySQL official connector, at least for objects constructor.
We talk here about MySqlParameter, but IMO, it applies to all public objects.

Why do that ?
To have a smooth and easy migration from official MySql connector to MySqlConnector :)

Make sense ?

Sebastien

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Nov 24, 2017

When MySqlDbType was implemented #362, this constructor overload was missed.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Nov 24, 2017

Fixed in 0.32.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