Skip to content

Implement more constructors to MySqlParameter #402

@Mimetis

Description

@Mimetis

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions