Walaa wrote:
You are using a UnitOfWork, and adding each entity to the UnitOfWork, with save recursively flag, but you did not associate them together. (i.e. nothing relates these entities to each other).
You should do something like.
var customer = new Customer();
customer.Name = "ABC";
...
var order = new Order();
order.Date = DateTime.Now;
...
customer.Orders.Add(order); // That's the trick
// recursive save using a DataAccessAdapter
adapter.SaveEntity(customer, false, true);
//Or using a UnitOfWork2
uow.AddForSave(customer, true); // and so you don't need to add the order to the UoW.
uow.Commit(adapter);
Hi Walaa, am glad that you are here to help me out. Yes I am using UnitOfWork2. I think I have done the same way you have said. Like you mentioned "don't need to add the order to the UoW". If you can help me with the code I have attached, it would be of great help.
And you said "nothing relates these entities to each other" in UOW. so using UOW how do i relate it ? because you said no need to add the order in the example you said while using UOW