diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/DbBind/MySqlDbBind.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/DbBind/MySqlDbBind.cs index 38280740a..2d95ba470 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/DbBind/MySqlDbBind.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/DbBind/MySqlDbBind.cs @@ -9,7 +9,14 @@ namespace SqlSugar { get { - throw new NotImplementedException(); + return new List>() + { + new KeyValuePair("tinyint",CSharpDataType.@byte), + new KeyValuePair("smallint",CSharpDataType.@short), + new KeyValuePair("mediumint",CSharpDataType.@int), + new KeyValuePair("int",CSharpDataType.@int), + new KeyValuePair("integer",CSharpDataType.@int), + }; } } } diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/MySqlProvider.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/MySqlProvider.cs index 5abdf8c1c..f6efc1412 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/MySqlProvider.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/MySqlProvider.cs @@ -1,13 +1,16 @@ -using System; +using MySql.Data.MySqlClient; +using System; +using System.Collections.Generic; using System.Data; using System.Data.SqlClient; -using MySql.Data.MySqlClient; - +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace SqlSugar { public class MySqlProvider : AdoProvider { - public MySqlProvider() {} + public MySqlProvider() { } public override IDbConnection Connection { get @@ -23,13 +26,10 @@ namespace SqlSugar base._DbConnection = value; } } - /// - /// Only SqlServer - /// - /// + public override void BeginTran(string transactionName) { - throw new NotImplementedException(); + ((MySqlConnection)this.Connection).BeginTransaction(); } /// /// Only SqlServer @@ -38,7 +38,7 @@ namespace SqlSugar /// public override void BeginTran(IsolationLevel iso, string transactionName) { - throw new NotImplementedException(); + ((MySqlConnection)this.Connection).BeginTransaction(iso); } public override IDataAdapter GetAdapter() { @@ -55,8 +55,8 @@ namespace SqlSugar } if (parameters.IsValuable()) { - IDataParameter[] ipars= ToIDbDataParameter(parameters); - sqlCommand.Parameters.AddRange((SqlParameter[])ipars); + IDataParameter[] ipars = ToIDbDataParameter(parameters); + sqlCommand.Parameters.AddRange((MySqlParameter[])ipars); } CheckConnection(); return sqlCommand; @@ -74,20 +74,24 @@ namespace SqlSugar public override IDataParameter[] ToIDbDataParameter(params SugarParameter[] parameters) { if (parameters == null || parameters.Length == 0) return null; - SqlParameter[] result = new SqlParameter[parameters.Length]; - int i = 0; - foreach (var paramter in parameters) + MySqlParameter[] result = new MySqlParameter[parameters.Length]; + int index = 0; + foreach (var parameter in parameters) { - if (paramter.Value == null) paramter.Value = DBNull.Value; - var p = new SqlParameter(); - p.ParameterName = paramter.ParameterName; - p.UdtTypeName = paramter.UdtTypeName; - p.Size = paramter.Size; - p.Value = paramter.Value; - p.DbType = paramter.DbType; - p.Direction = paramter.Direction; - result[i] =p; - ++i; + if (parameter.Value == null) parameter.Value = DBNull.Value; + var sqlParameter = new MySqlParameter(); + sqlParameter.ParameterName = parameter.ParameterName; + sqlParameter.Size = parameter.Size; + sqlParameter.Value = parameter.Value; + sqlParameter.DbType = parameter.DbType; + sqlParameter.Direction = parameter.Direction; + result[index] = sqlParameter; + if (sqlParameter.Direction == ParameterDirection.Output) { + if (this.OutputParameters == null) this.OutputParameters = new List(); + this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName); + this.OutputParameters.Add(sqlParameter); + } + ++index; } return result; }