저는 저장소 패턴과 종속성 삽입을 처음 접했습니다. 거의 내가 건너 한 모든 저장소 패턴과 같이 GETALL() 메소드의 어떤 종류가 있습니다저장 프로 시저가있는 저장소 패턴
public interface IRepository<T>
{
IQueryable<T> GetAll();
// other CRUD methods here...
}
내가 저장 프로 시저를 호출하고 있기 때문에이 인터페이스와 GETALL() 메소드를 구현하는 문제에 봉착를 그 사용자의 입력에 따라 변경되는 매개 변수가 필요합니다. 예를 들어 저장소 인터페이스에 ad-hoc 메서드를 추가하고 싶지 않습니다. IQueryable<T> GetAll(string input);
. 나는 또한 내가 바인딩 할 때 생성자에 일부 동적 입력을 추가해야 의존성 주입을 사용하고
public class ConcreteRepository : IRepository<Entity>
{
string _storedProcedureInput;
public ConcreteRepository(string storedProcedureInput)
{
_storedProcedureInput = storedProcedureInput;
public IQueryable<Entity> GetAll()
{
// Call to stored procedure goes here passing in the
// _storedProcedureInput variable.
}
}
: 그것은 나에게 좀 지저분를 보이기 때문에 나는 또한 생성자에 매개 변수를 추가하지 않으 :
Bind<IRepository<Entity>>().To<ConcreteRepository>().WithConstructorArgument(?)
의견이 있으십니까?
업데이트 : 내가 IRepository 인터페이스를 다시 사용할 수 있도록
. 예를 들어, 한 프로그램에서 EF4를 사용하여 GetAll() 메서드를 구현하고 다른 프로그램에서는 표준 ADO.NET을 사용하여 위의 예제와 같은 저장 프로 시저를 호출합니다.
코드는 절대적으로 그리고 repostitory 패턴에 따라 절대적으로 보인다. –