public static void T_StoreProcMultiResultSet2() { var connStr = GetMySqlConnString(); var conn = new MySqlConnection(connStr); //Console.WriteLine("1"); conn.Open(); PrepareTable1(conn); // Console.WriteLine("2"); { string createStoreProcSql = @"DROP PROCEDURE IF EXISTS multi;"; var cmd = new MySqlCommand(createStoreProcSql, conn); // Console.WriteLine("3"); cmd.ExecuteNonQuery(); } { string createStoreProcSql = @"CREATE PROCEDURE multi() BEGIN SELECT 1011 as A; SELECT 1022 as B; select col_id from test001; END"; //Console.WriteLine("4"); var cmd = new MySqlCommand(createStoreProcSql, conn); cmd.ExecuteNonQuery(); } { // Console.WriteLine("5"); string callProc = "call multi();"; var cmd = new MySqlCommand(callProc, conn); var reader = cmd.ExecuteReader(); //access to sub table MySqlSubTable currentSubTable; while (reader.Read()) { MySqlSubTable subTable = reader.CurrentSubTable; if (subTable != currentSubTable) { //change to new table currentSubTable = subTable; } // Console.WriteLine("6"); //we read each row from int data1 = reader.GetInt32(0); Console.WriteLine(data1); } //Console.WriteLine("7"); reader.Close(); } //-------------------------- conn.Close(); // Report.WriteLine("ok"); }
protected void EvaluateTargetStructure(Type t) { //evaluate target objet definition //check current table defintioin first *** MySqlSubTable subTable = reader.CurrentSubTable; //get all public instance fields from current type FieldInfo[] allFields = GetPublicInstanceFields(t); //we iterate all request fields int j = allFields.Length; mapFields.Clear(); for (int i = 0; i < j; ++i) { FieldInfo field = allFields[i]; MySqlFieldDefinition fieldDef = subTable.GetFieldDefinition(field.Name); //---------------------------------- //check field type conversion //1. some basic can do direct conversion //2. use can provide custom protocol for field conversion //3. some need user decision //---------------------------------- //in this version we support only primitive type *** MySqlDataConversionTechnique foundConv; if (!MySqlTypeConversionInfo.TryGetImplicitConversion((MySqlDataType)fieldDef.FieldType, field.FieldType, out foundConv)) { //not found //TODO: //so make notification by let use make a dicision throw new NotSupportedException(); } //----------------- MySqlFieldMap fieldMap = fieldDef.IsEmpty ? new MySqlFieldMap(-1, fieldDef.Name, foundConv) : new MySqlFieldMap(fieldDef.FieldIndex, fieldDef.Name, foundConv); fieldMap.resolvedFieldInfo = field; mapFields.Add(fieldMap); } }
protected void EvaluateTableDefinition(MethodInfo met) { //check current table defintioin first *** MySqlSubTable subTable = reader.CurrentSubTable; var metPars = met.GetParameters(); //target method that we need int j = metPars.Length;//** mapFields.Clear(); for (int i = 1; i < j; ++i) { //get parameter fieldname //and type and check proper type conversion ParameterInfo metPar = metPars[i]; MySqlFieldDefinition fieldDef = subTable.GetFieldDefinition(metPar.Name); //---------------------------------- //check field type conversion //1. some basic can do direct conversion //2. use can provide custom protocol for field conversion //3. some need user decision //---------------------------------- //in this version we support only primitive type *** MySqlDataConversionTechnique foundConv; if (!MySqlTypeConversionInfo.TryGetImplicitConversion((MySqlDataType)fieldDef.FieldType, metPar.ParameterType, out foundConv)) { //not found //TODO: //so make notification by let use make a dicision throw new NotSupportedException(); } //----------------- MySqlFieldMap fieldMap = fieldDef.IsEmpty ? new MySqlFieldMap(-1, fieldDef.Name, foundConv) : new MySqlFieldMap(fieldDef.FieldIndex, fieldDef.Name, foundConv); mapFields.Add(fieldMap); } }