本文发表在 rolia.net 枫下论坛and those children might even have cascade relationship
some children are 1-to-1, some are 1-to-many
however, I do agree I can adopt your method, basically similar to how I solve it before
I was planning to create a bunch DTOs
for example, originally, I have
Employee
- EmployeeEnrollment (1-to-many)
- EmployeeDependent (1-to-many)
- other 30 children
and one service operation each for CRUD
GetEmployee : Employee
If call this service op, it will serialize the request for all children, then fetch everything back from the service side (BAD)
My plan was to have
- EmployeeDTO
- EmployeeEnrollmentDTO
- EmployeeDependent
these DTO objects have no relationship, purely represents the table only
and I still have one operation GetEmployee : Employee, but internally, it becomes
return serviceClient.GetEmployeeDTO ( id ).ToEmployee()
so in my service agent, I have to translate the fetched DTO to the real entity
now, each child entity will need to have a virtual list, similar to what you do, if the entity has not been loaded, I will launch another DTO call, i.e. GetEmployeeEnrollmentDTO ( employeeId ) , then translate it
so I will end up having a lot of sub-service operations and more entities, but I can use t4 to generate them, that's not really a big problem
what do u think of it?更多精彩文章及讨论,请光临枫下论坛 rolia.net
some children are 1-to-1, some are 1-to-many
however, I do agree I can adopt your method, basically similar to how I solve it before
I was planning to create a bunch DTOs
for example, originally, I have
Employee
- EmployeeEnrollment (1-to-many)
- EmployeeDependent (1-to-many)
- other 30 children
and one service operation each for CRUD
GetEmployee : Employee
If call this service op, it will serialize the request for all children, then fetch everything back from the service side (BAD)
My plan was to have
- EmployeeDTO
- EmployeeEnrollmentDTO
- EmployeeDependent
these DTO objects have no relationship, purely represents the table only
and I still have one operation GetEmployee : Employee, but internally, it becomes
return serviceClient.GetEmployeeDTO ( id ).ToEmployee()
so in my service agent, I have to translate the fetched DTO to the real entity
now, each child entity will need to have a virtual list, similar to what you do, if the entity has not been loaded, I will launch another DTO call, i.e. GetEmployeeEnrollmentDTO ( employeeId ) , then translate it
so I will end up having a lot of sub-service operations and more entities, but I can use t4 to generate them, that's not really a big problem
what do u think of it?更多精彩文章及讨论,请光临枫下论坛 rolia.net