动态编译

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();
}

posted on 2012-08-31 00:27  萌二&威比  阅读(210)  评论(0编辑  收藏  举报

导航