/// <summary> /// if mysql return MySqlParameter[] pars /// if sqlerver return SqlParameter[] pars ... /// </summary> /// <param name="parameters"></param> /// <returns></returns> public override IDataParameter[] ToIDbDataParameter(params SugarParameter[] parameters) { if (parameters == null || parameters.Length == 0) { return(null); } KdbndpParameter[] result = new KdbndpParameter[parameters.Length]; int index = 0; foreach (var parameter in parameters) { if (parameter.Value == null) { parameter.Value = DBNull.Value; } var sqlParameter = new KdbndpParameter(); sqlParameter.ParameterName = parameter.ParameterName; sqlParameter.Size = parameter.Size; sqlParameter.Value = parameter.Value; sqlParameter.DbType = parameter.DbType; sqlParameter.Direction = parameter.Direction; if (parameter.IsJson) { sqlParameter.KdbndpDbType = KdbndpDbType.Json; } if (parameter.IsArray) { // sqlParameter.Value = this.Context.Utilities.SerializeObject(sqlParameter.Value); var type = sqlParameter.Value.GetType(); if (ArrayMapping.ContainsKey(type)) { sqlParameter.KdbndpDbType = ArrayMapping[type] | KdbndpDbType.Array; } else { Check.Exception(true, sqlParameter.Value.GetType().Name + " No Support"); } } if (sqlParameter.Direction == 0) { sqlParameter.Direction = ParameterDirection.Input; } result[index] = sqlParameter; if (sqlParameter.Direction.IsIn(ParameterDirection.Output, ParameterDirection.InputOutput, ParameterDirection.ReturnValue)) { if (this.OutputParameters == null) { this.OutputParameters = new List <IDataParameter>(); } this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName); this.OutputParameters.Add(sqlParameter); } ++index; } return(result); }