|
/// <summary>
/// A UserContextUnitOfWork instance that represents the run-time implementation of the IUserContextUnitOfWork interface.
/// </summary>
public class UserContextUnitOfWork : DbUnitOfWork<UserContext>, IUserContextUnitOfWork
{
public UserContextUnitOfWork(Func<UserContext> contextFactory)
: base(contextFactory)
{
}
IRepository<User, int> IUserContextUnitOfWork.Users
{
get { return GetRepository(x => x.Set<User>(), (User x) => x.Id); }
}
IRepository<UserInfo, int> IUserContextUnitOfWork.UserInfos
{
get { return GetRepository(x => x.Set<UserInfo>(), (UserInfo x) => x.Id); }
}
IRepository<Role, int> IUserContextUnitOfWork.Roles
{
get { return GetRepository(x => x.Set<Role>(), (Role x) => x.Id); }
}
IRepository<Retry, int> IUserContextUnitOfWork.Retries
{
get { return GetRepository(x => x.Set<Retry>(), (Retry x) => x.Id); }
}
IRepository<Category, int> IUserContextUnitOfWork.Categories
{
get { return GetRepository(x => x.Set<Category>(), (Category x) => new { x.CatListNum, x.RoleId }); }
}
}
在搭建Scaffolded Application时,unitofwork的基础类里实体Category中我没有ID主键,我使用(new { x.CatListNum, x.RoleId)做联合主键,但VS报错提示GetRepository(x => x.Set<Category>(), (Category x) => new { x.CatListNum, x.RoleId })不能隐式转换为IRepository<Category, int>的类型,诸位有能解决这个问题的不?
|
|