参考http://stackoverflow.com/questions/19641031/get-table-objectset-based-on-table-name-entity-framework
public IQueryable<T> GetTable<T>() where T : class
{
var table = m_entities.CreateObjectSet<T>();
return table;
}
以增加为例,说明如何利用泛型来进行CRUD(Create,Read,Update,Delete)
public bool Insert<T>(T obj) where T:class
{
m_entities.CreateObjectSet<T>().AddObject(obj);
int res = m_entities.SaveChanges();
return (0 < res);
}