검색결과 리스트
글
Domain Service Class에서 각 Operation들을 사용할 때의 규칙을 정리해 보겠습니다.
[ Insert ]
- void 형이어야 할 것. 첫번째 파라미터로 Entity에 해당하는 객체가 올 것
- 접두어가 Insert / Add / Create 중 하나일 것
public void InsertEmployee(Employee newEmployee) {...}
- 단, 앞에 [Insert] 속성을 붙이면 함수 이름은 관계없음
[Insert]
public void YourFavoriteMethodName(Employee newEmployee) {...}
[ Update ]
- void 형이어야 할 것. 첫번째 파라미터, 혹은 첫번째와 두번째 파라미터로 Entity에 해당하는 객체가 올 것
- 접두어가 Update / Change / Modify 중 하나일 것
public void UpdateEmployee(Employee changedEmployee, Employee
originalEmployee)
- 단, 앞에 [Update] 속성을 붙이면 함수 이름은 관계없음
[Update]
public void YourFavoriteMethodName(Employee changedEmployee, Employee
originalEmployee)
[ Delete ]
- void 형이어야 할 것. 첫번째 파라미터, 혹은 첫번째와 두번째 파라미터로 Entity에 해당하는 객체가 올 것
- 접두어가 Delete / Remove 중 하나일 것
public void DeleteEmployee(Employee currentEmployee, Employee
originalEmployee)
- 단, 앞에 [Delete] 속성을 붙이면 함수 이름은 관계없음
[Delete]
public void YourFavoriteMethodName(Employee currentEmployee, Employee
originalEmployee)
[ Query ]
- 리턴형은 IEnumerable<T>나 IQueryable<T>. 이때 T는 엔티티여야 함
- 접두어가 Get / Fetch / Find / Query / Retrieve / Select 중에 하나일 것
public IQueryable<Employee> GetEmployee() {...}
- Generated Code 단으로 가면 이름이 바뀔 가능성이 있음. 즉 GetEmployee()라고 Domain Service Class에서 썼다면,
이는 Employee 엔티티를 '얻는' 개념. Generated로 가는 클라이언트에선 Employee를 '읽는' 개념. 이렇게 바뀌긴 하지만
그냥, 바뀐 이름으로 호출하면 끝나는 문제
- [Query] 속성을 붙여서 명확히 표시해줄 수 있음 (꼭 필요하진 않아요)
[Query]
public IQueryable<Employee> GetEmployee() {...}
- 쿼리를 멀티로 짤 수도 있지만, 조심해야합니다. 예를 들어 GetEmployee와 FetchEmployee로 두 오퍼레이션을 짰다면,
클라이언트단에선 전부 LoadEmployee()로 변할 수 있고, 이 과정에서 에러가 날 수가 있습니다.
- 속성에 PreserveName = true로 하면, 클라이언트단으로 갈 때 메서드 이름이 바뀌지 않음
[Query(PreserveName=true)]
public IQueryable<Employee> GetEmployee() {...}
[ Custom ]
- void형이어야 할 것. 첫번째 인자로 Entity형이 와야하고, Insert, Update, Delete 형태의 로직이 아니어야 할 것
public void ApproveEmployee(Employee changedEmployee, ...)
- [Custom] 속성을 붙여서 명확히 표시해줄 수 있음 (꼭 필요하진 않아요)
[Custom]
public void ApproveEmployee(Employee changedEmployee, ...)
[ Resolve ]
- bool형이어야 할 것. 인자는 세개의 Entity 필요.
- 접두어는 무조껀 Resolve여야 할 것
public bool ResolveEmployee(PurchaseOrder currentEmployee, PurchaseOrder originalEmployee, PurchaseOrder storeEmployee, bool deleteOperation)
- Update 의 로직구현이 필요합니다. 별도의 속성은 없습니다.
[ Service Operation ]
- [ServiceOperation] 속성을 반드시 붙여야 함. 그 이외에는 제약사항 없음.
[ServiceOperation]
public byte[] GetProductImage(){...}
[ Opt-Out ]
- Omit~♡
[IgnoreOperation]
public void InsertEmployee(Employee newEmployee) {...}
- 클라이언트 코드로 전달되지 않는다.
----------------------------------------------------------------------------------------------------------------
지금까지 일반적인 오퍼레이션의 사용법에 대해서 알아보았습니다. 그닥 특별한 내용이 없네요.
다음 포스팅은 '메타데이터를 사용하는 방법' 에 대해서.입니다.
감사합니다.
RECENT COMMENT