Home  /  Questions  /  Question



Sep 29, 2010


How to implement CRUD operations for complex objects?

Hi!

My name is Fernando López Guevara, I'm from Argentina.
Sorry for my English. It's not so good =)

I was reading the code of the Design Pattern Framework 4 and noticed that it shows how to implement CRUD operations for a single entity like Customer.  I was wondering how to write CRUD operations with complex objects, for example Order with several OrderDetails; This should include the Unit of Work pattern. Correct?

I hope you understand my question'

Thanks and cheers.




588   99.9
Nov 03, 2010
Fernando,

The answer really depends on your data infrastructure.

If you are using the Entity Framework 4, it was built-in ways of updating relational data when the parent data is updated.  If you are using straight ADO.NET, then you simply have to write functions to collect the related OrderDetails for the Order and loop through each detail and update for that Order.

And yes, you can use the Unit of Work pattern.  But it mostly depends on how your data layer is built.  Is it already using an ORM like EF4 or Linq-To-Sql, etc., or is it completely hand coded with ADO.NET?  Those are the determining factors.

I hope that helps.

60   95.3
Jan 23, 2011
Use LINQ Managed Entity.At first you might scratch your head once this phase pass by it will be very easy to manage

50   50
Feb 01, 2011
You can use NHibernate for crud operation :)