This project is read-only.

CODE FW approach for dealing with 1-many relationships

Apr 12, 2013 at 6:04 PM
Edited Apr 23, 2013 at 10:59 PM
EF makes it easy to create a 1-M relationship and automatically gets the data for the child tables. Assuming I will be using the services approach, I will need to package the data and pass it to the client.

There are a number of ways I can try to do this. Are there any examples of how best to pass such data sets? In my case, I have some forms that have a number of detail data sets.

I am assuming I just create lists of the child details and include those in the response object the same way I return sets of the primary data in the getAll response object. Does the framework make any assumptions based on the names I use for these lists/collections?

Apr 26, 2013 at 6:15 PM
Assuming you go the service route, you would create yourself a data contract for your service that includes sub-elements. For instance, you could create a customer data contract that has a List<Order> for all the orders the customer has and each order can have a List<LineItem>. Order and Line item are also data contracts. Then, you take whatever data source you have (EF in your example, but it really doesn't matter) and map into those contracts. We have a Mapper object in CODE Framework that can help you with that.