使用泛型可以在不知道类型的情况下从EntityFramework获取对象吗?
我在想一些大致如下的事情:
public T GetObjectByID<T>(int id)
{
return (from i in myDatabase.T where i.ID == id select i);
}
这可行吗?我可以用反射法取T.GetType().Name
,然后用它来做桌子吗?
EDIT
Another hangup, is that not all tables available to me use "ID" as their unique column name.