0
我有几个类:User.cs
,Permission.cs
,依此类推......他们都是BaseCore.cs
的子女,其中所有的主要逻辑是。按类别收集的实体
这里是我dbContext
类(简体):
public class MyContext : DbContext {
public MyContext() : base("AppEntityDB") {
System.Data.Entity.Database.SetInitializer(new DropCreateDatabaseAlways<MyContext>());
}
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<Permissions> Permissions { get; set; }
}
现在我创建baseListForm.cs
,这将是所有ListForms的父(Windows窗体aplication)
我想baseListForm
有像所有基本功能SaveData();
EditData()
和LoadData()
;
这里是我BaseListForm
类(简体):
public partial class BaseListForm : Form {
private BaseCore _classType;
public virtual void LoadList() {
//I want here to load the collection of Mycontext() depending
// on what which class it calls. eg. if User.cs calls then i want
// to call DbSet<User> Users collection (accessible - _classType.Users)
var LoadCurrentClass = ClassType.
}
}
所以我想以某种方式选择MyContext()
相应的集合this.GetType();
类。