I have an application where a client communicates with a server side through REST. This is written in .Net, but I guess the question should be independent of this.
Now - I have services such as GetAllCustomers
and GetCustomerById
. A Customer has references to a potentially big list of Order, so I don't want to pass the Customers references from the GetAllCustomers
service. I basically want to return the Customers with their simple data, but no references. Then I will do another service call GetCustomerById
to fetch the complete data when a Customer is selected in the client.
The question now is - is there a recommended way of handling this? Using Lazy Loading I can simply pass the object before the references are loaded - and then make sure this isn't used on the client side. But is this ugly? (Also - I got problems communicating lazy loaded objects with REST, but it worked with SOAP - but this is a different question..) I guess I could fetch all data from the database and then delete the references before I return it, but this sure sounds hacky. Also I still get unnecessary load on my database..
So; is there a good solution to this?