动态编译

string oradb = @"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.212.130)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME=orcl.elliott)));
User Id=xujialiang;Password=3.1415926;";
OracleConnection conn = new OracleConnection();
try
{
conn.ConnectionString = oradb;
conn.Open();
string sql = "select field,fieldtype from fielddescription"; // C#
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.CommandType = CommandType.Text;

OracleDataReader dr = cmd.ExecuteReader(); // C#
Dictionary<string, string> contents = new Dictionary<string, string>();
while (dr.Read())
{
contents.Add(dr["field"].ToString(), dr["fieldtype"].ToString());
}

Assembly aaa = dynamicentity.NewEntity("myentity",contents);
dynamic tmp = aaa;
Response.Write(tmp.Title);
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
finally
{
conn.Clone();
}

你可能感兴趣的:(动态编译)