前幾天我決定使用工作單元&通用存儲庫在我的項目中。經過一番搜索I found this solution來做到這一點。ASP MVC將ApplicationUser添加到通用存儲庫
在這個模式中,我們有4層:
1. UI
2. Model
3. Repository
4. Service
點是在模型層Entity
類的所有域模型的繼承。例如:
public class Project : Entity<int> {
...
}
這是我Entity
類:
public abstract class BaseEntity { }
public abstract class Entity<T> : BaseEntity, IEntity<T>
{
public virtual T Id { get; set; }
}
現在,當我要加入ApplicationUser
類UOF模式我得到一個錯誤,這個概念是ApplicationUser
不是來自BaseEntity
繼承。
提示:
ApplicationUser
是IdentityUser
類
繼承最新最好的做法ApplicationUser
添加到我的設計模式?
UPDATE
我IApplicationUserService
接口得到錯誤信息
public interface IApplicationUserService : IEntityService<ApplicationUser>
{
Task<Part> GetById(int? id);
}
IEntityService:
public interface IEntityService<T> : IService
where T : BaseEntity
{
void Create(T entity);
void Delete(T entity);
Task<List<T>> GetAllAsync();
IEnumerable<T> GetAll();
Task Update(T entity);
}
請自行顯示錯誤。尚不清楚它來自哪裏。 –
請再看一遍。 – user3748973