【发布时间】:2010-06-26 13:46:34
【问题描述】:
我有这个实现存储库模式的基本抽象类
public abstract class Repository<T> : IRepository<T> where T : class
{
private ObjectSet<T> _entitySet;
private ObjectContext _dataContext;
public Repository(ObjectContext context)
{
_dataContext = context;
_entitySet = _dataContext.CreateObjectSet<T>();
}
public T FindByID(int id)
{
//??????
}
}
现在我需要知道主键列(对应属性)来实现 FyndByID 方法。
建议主键不是复合的,它的数据类型是int
【问题讨论】:
-
它是否必须与数据库无关,或者特定于 SQL Server 的版本是否适合您?
标签: entity-framework repository repository-pattern