내 IService에는 IRepository의 모든 것과 특정 작업이 더 있다고 할 수 있습니까? IRepository
의 모든 작업이 IService
도 있습니다IService는 IRepository를 확장합니까?
public interface IRepository<T>
{
T Add(T Entity);
T Remove(T Entity);
IQueryable<T> GetAll();
}
public interface IUserService
{
//All operations IRepository
User Add(User Entity);
User Remove(User Entity);
IQueryable<User> GetAll();
//Others specific operations
bool Approve(User usr);
}
참고 :
다음은 코드입니다.
이 정보가 맞습니까? 또 다른 옵션이 될 것
public interface IUserService : IRepository<User>
{
bool Approve(User usr);
}
:
그렇다면,이 같은 뭔가를 더 좋을 거라 내가 속성으로 저장소를 넣어
public interface IUserService
{
IRepository<User> Repository { get; }
//All operations IRepository
User Add(User Entity);
User Remove(User Entity);
IQueryable<User> GetAll();
//Others specific operations
bool Approve(User usr);
}
public class UserService : IUserService
{
private readonly IRepository<User> _repository;
public IRepository<User> Repository
{
get
{
return _repository;
}
}
//Others specific operations
public bool Approve(User usr) { ... }
}
참고하고, 내 서비스 수업에서이 물건을 드러내고있어.
그래서 저장소에 개체를 추가, 제거 또는 가져와야하는 경우이 속성을 통해 액세스 할 수 있습니다.
귀하의 의견은 무엇입니까? 이 작업을 올바르게 했습니까?
는 플래그되는 질문을 방지하고 ... 모든 대답은 동등하게 유효한 경우 가능한 제거, 주관적인 질문을 피하려면 : "좋아하는 무엇 ______" 당신의 대답은 질문과 함께 제공되며, 당신은 더 많은 답변을 기대합니다 : "나는 ______에 ______을 사용하는데 무엇을 사용합니까?" 해결할 실제 문제는 없습니다. "다른 사람들이 내가하는 것처럼 느낀다면 궁금합니다." 우리는 개방적이고 가상적인 질문을 받고 있습니다. : "______이 (가) 일어난다면 어떨까요?" 질문으로 가장 한 호언 장담이다. "______는 빤다. 맞다." – cadrell0
어쩌면 질문하는 법을 모르겠습니다. 내가 알고 싶은 것은 어떻게 내 저장소의 메소드를 노출 시키는가입니다. 내 서비스에서 속성으로 속성을 노출하거나 저장소의 메서드에 액세스하는 메서드를 만드는 경우 – ridermansb
@ cadrell0 : 그는 3 가지 가능한 방법을 제시하고 주관적인 이유가 아니라 객관적인 이유를 위해 그가 사용해야하는 질문을했습니다. –