1

나는 POCO 클래스를 10 개했습니다. IRespoitory 인터페이스 및 UnitOf 작업 클래스와 함께 작업 단위 (UOW)와 함께 간단한 저장소 패턴을 사용하고 있습니다.단위 작업 관련 저장소

모든 IRepository를 단일 UnitOfWork 인스턴스에 넣는 것이 맞습니까 (보통)? 즉

: 10 POCO 클래스 - IRepository 10 예 - 하나의 UnitOfWork 클래스 모두 10 저장소

UnitOfWork 
{ 
IRepository<Customer> CustomerRepository {get; set;} 
IRepository<Customer> CustomerRepository {get; set;} 
IRepository<Customer> CustomerRepository {get; set;} 
// the same for all others 7 POCo class 
// ..other stff 
} 

답변

0

그것은 EF의 DataContext 같은 약간의가 포함되어 있습니다. EntityFramework의

의 DataContext 작업장치와 (당신의 저장소 또는 수집)을 저장소 같은 작은입니다.

필자는 이러한 것들을 분리하고 dependency injection framework (structuremap과 같은)을 사용하는 것을 선호합니다.

구조판IRepository<Customer>을 요청하면 인스턴스가 제공됩니다.

별거 리포지토리. 당신은 (같은 방법으로 : SubmitChanges) 하나 개 UOW 클래스를 가질 수

다음과 당신의 저장소 (같은 방법으로 각 : Add, Delete, ...)

관련 문제