已知dEntities是一个ObjectContext对象
table1是dEntities里的一个实体名 (table1是一字符串)现在想用反射的方法调用
dEntities.table1.Attach(mm)方法我这样写反射代码老是出错误,应该怎么修改
dEntities ent=new dEntities()
if (ent.GetType().GetProperty("table1")!=null) //这里一直为空
var md=ent.GetType().GetProperty("table1").GetType().GetMethod("Attach") //获取Attach方法
table1是dEntities里的一个实体名 (table1是一字符串)现在想用反射的方法调用
dEntities.table1.Attach(mm)方法我这样写反射代码老是出错误,应该怎么修改
dEntities ent=new dEntities()
if (ent.GetType().GetProperty("table1")!=null) //这里一直为空
var md=ent.GetType().GetProperty("table1").GetType().GetMethod("Attach") //获取Attach方法
if (ent.GetType().GetProperty("table1",BindingFlags.Instance|BindingFlags.Public)!=null)
试了,仍然为NULL
string entitySetName, //表示实体集名称,可以选择通过实体容器名称对它进行限定。
Object entity
)
已知dEntities是一个ObjectContext对象
table1是dEntities里的一个实体名 (table1是一字符串)
都说了啊实体是Entity自动生成的
public ObjectSet<table1> table1
{
get
{
if ((_table1 == null))
{
_table1 = base.CreateObjectSet<table1>("table1");
}
return _table1;
}
}