I have a question regarding the use of composition in OpenEdge classes.
I come from a C# / Java background and it looks like OpenEdge takes a different approach here.
We have a use case where an order should be added to the database.
In C# (using Entity Framework) I would create some entities like Order, OrderLine and Customer
The way the entity classes would be build is like this:
class Order {
public int OrderId {get; set; }
public int CustomerId {get; set; }
public virtual Customer Customer { get; set; }
public virtual ICollection<OrderLine> OrderLines {get; set; }
}
class Customer {
public int CustomerId {get; set; }
public virtual ICollection<Order> Orders { get; set; }
}
class OrderLine {
public int OrderLineId {get; set; }
public int OrderId { get; set; }
public virtual Order Order {get; set; }
}
I have done several OpenEdge courses but am still trying to get all the pieces into the right place here.
Like in the IntroToOOP course I can see that I would have to use an order temp-table with a CustomerObj field. And the Customer object would hold a temp-table containing all the customer info. But then what would I do with all the properties for Customer.
When a property updates, that that would have to be changed in the Customer object and in the Customer temp-table.
What I would like to do is just use a AddOrder() method in the Customer class to create a new order, and then do something like customer:order:AddOrderLine().
What would be the best way to accomplish this in OpenEdge?
Hi Peter, so it is like any other language. :)
Although it would be easier sometimes to have "One Ring to rule them all".