class Query
{
public Dictionary<string, string> RunQueryWithParameters(string sim_input,string CommandTxt, Dictionary<string, string> parameters)
{
OracleDataReader reader = cursCmd.ExecuteReader();
if(reader.HasRows)
{
while (reader.Read())
{
ods_columns.Add("mob_no", reader.GetString(0));
ods_columns.Add("card_no", reader.GetString(1));
ods_columns.Add("account", reader.GetString(2));
ods_columns.Add("name", reader.GetString(3));
reader.NextResult();
}
Console.ReadLine();
reader.Close();
reader.Dispose();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
conn.Close();
}
return columns;
}
}
但没有返回任何价值。请帮助#
static void main()
{
Dictionary<string, string> result=new Dictionary<string,string>;
sting input="test";
Query test=new Query();
Query.RunQueryWithParameters(input,string "GET_DOC_DATA", result);
console.writeline(result["mob_no"]);
console.writeline(result["card_no"]);
console.writeline(result["account"]);
console.writeline(result["name"]);
}
答案 0 :(得分:0)
直接使用ToDictionary
方法。
var result =
// as Jon Skeet pointed out, OrderBy is useless here, I just leave it
// show how to use OrderBy in a LINQ query
myClassCollection.OrderBy(mc => mc.SomePropToSortOn)
.ToDictionary(mc => mc.KeyProp.ToString(),
mc => mc.ValueProp.ToString(),
StringComparer.OrdinalIgnoreCase);