如何反映 EntityObject 列表?
我查遍了整个网络,似乎找不到合适的解决方案。我是实体框架方面的菜鸟。我所从事的工作是我非常喜欢的。在过去的项目中,我已经能够提取一个对象字典,以便稍后使用,如下所示:
Dictionary<string, MyBaseType> myTypes = new Dictionary<string, MyBaseType>();
var types = Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.BaseType != null && t.BaseType.Name.Equals("MyBaseType")).ToArray();
object ct;
foreach (Type c in types)
{
ct = Activator.CreateInstance(c);
myTypes.Add(ct.GetType().Name, ct as MyBaseType);
}
var myob = myTypes["SomeName"];
myob.DoFoo(); // this is a method of my basetype class or my interface
我需要为带有 EF4 的 MVC 项目执行类似的操作。我尝试使用 EntityObject 作为基本类型,但无论出于何种原因,执行程序集都不会反映它们。
有什么想法吗?
I've looked all over the net and can't seem to find a decent solution. I'm a noob regarding Entity Framework. What I've been able to work with I really like. In past projects, I've been able to pull a Dictionary of objects that I can use later like this:
Dictionary<string, MyBaseType> myTypes = new Dictionary<string, MyBaseType>();
var types = Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.BaseType != null && t.BaseType.Name.Equals("MyBaseType")).ToArray();
object ct;
foreach (Type c in types)
{
ct = Activator.CreateInstance(c);
myTypes.Add(ct.GetType().Name, ct as MyBaseType);
}
var myob = myTypes["SomeName"];
myob.DoFoo(); // this is a method of my basetype class or my interface
I need to do something similar for an MVC w/ EF4 project. I tried using EntityObject as the base type, but for whatever reason, the Executing Assembly won't reflect them.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须检查:
You have to check: