[英]How to pass connection options while using UnitOfWork. C# Entity Framework, dependency injection, Sqlite, unit of work [on hold]
[英]Entity framework, IRepository and UnitOfWork. How do you implement DAL?
使用EF 實現Repository的規范實現如下:
public interface IStudentRepository : IDisposable
{
IEnumerable<Student> GetStudents();
Student GetStudentByID(int studentId);
void InsertStudent(Student student);
void DeleteStudent(int studentID);
void UpdateStudent(Student student);
void Save();
}
在這里,我看到IRepository,UnitOWork的混合。
但Fowler說存儲庫是用於訪問域對象的類似集合的接口 。 據此,Update,Delete和Insert方法應該移動到另一個類。 以及Save應該移動到實現IUnitOfWork的類。
在我目前的項目中,我們實施IRepository作為官方文檔說。 它可以在將來引起問題嗎? 一種解決方案是實施CQRS,可能采用事件源,但需要時間和資源。 那么,您如何在項目中實施DAL?
你在那里有什么不對。
我唯一需要做的就是為我的存儲庫創建一個單獨的工廠,它是DataService類的一部分。 DataService類將傳遞存儲庫實例
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.