private object[] ExecuteCommandWithProc(DbCommand command) { string[] result = command.CommandText.MatchWithParamP(); command.Parameters.Clear(); DbParameter[] parameters = new DbParameter[result.Length]; for (int i = 0; i < result.Length; i++) { parameters[i] = command.CreateParameter(); parameters[i].ParameterName = result[i]; parameters[i].Direction = ParameterDirection.Output; parameters[i].Size = 255; } command.Parameters.AddRange(parameters); command.ExecuteNonQuery(); return(parameters.Select(x => x.Value).ToArray()); }
protected void ConvertBatchParameters <T>(T model, ref DbParameter[] parameters, ref StringBuilder scriptBlock, int index) { if (index >= 1) { scriptBlock.AppendLine(" UNION ALL "); } parameters = new DbParameter[Entity <T> .ColumnsPropertyWithOutReadony.Length]; DbParameter parm = null; for (int i = 0; i < Entity <T> .ColumnsPropertyWithOutReadony.Length; i++) { parm = this._command.CreateParameter(); parm.Value = Entity <T> .ColumnsPropertyWithOutReadony[i].GetValue(model, null) != null ? Entity <T> .ColumnsPropertyWithOutReadony[i].GetValue(model, null) : DBNull.Value; parm.ParameterName = Entity <T> .Properties[Entity <T> .ColumnsPropertyWithOutReadony[i].Name].ParameterName + index.ToString(); parm.DbType = Entity <T> .Properties[Entity <T> .ColumnsPropertyWithOutReadony[i].Name].ColumnType; parameters[i] = parm; } scriptBlock.AppendLine(string.Format("SELECT {0}", string.Join(",", parameters.Select(s => s.ParameterName)))); }