What way should I do this

Posts   
 
    
G.I.
User
Posts: 172
Joined: 09-Jun-2005
# Posted on: 09-Jun-2005 21:24:35   

Hi,

in my program I have 2 kinds of orderlines. TypeA and TypeB. They have a lot of things in common, but also a few different properties and rules. They are stored in the same table, where some fields have value NULL because those are used by the other type.

In this table I have a PK of two columns, ProjectID and TaskID. For each task there can be one order with multiple orderlines, which can be of both types.

Each orderline will have a line number. When I store the orderlines in the table, I want to insert the TypeA lines first, starting from 1 till how many there are, for example 8.

After that I want to insert the TypeB lines, which have to start with 9 till how many there are.

I have to do this, because of the orders that have to be created and synchronized with some other tables at some point.

This actually mean I should have 2 entities and probably an OrderManager to make sure the orderlines are inserted correctly, but how do I do this? What is the best way to implement this ?

Gr.,

G.I.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 10-Jun-2005 09:46:11   

I think some sort of pre-save actions have to be performed before you save the entities to the database. Because the types are different, I definitely would add a type describing column to the table, for example of type int, which describes of which type the row is. You can then use that to sort the entities in the collection, prior to save them.

With 1.0.2005.1, in development now, you will be able to define the types in the designer based on the type describing column.

Frans Bouma | Lead developer LLBLGen Pro
G.I.
User
Posts: 172
Joined: 09-Jun-2005
# Posted on: 10-Jun-2005 10:21:24   

Sounds good...but I am will need two collections, since I have to bind them to two different datagrids, one for TypeA and one for TypeB on different forms.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 10-Jun-2005 10:53:17   

G.I. wrote:

Sounds good...but I am will need two collections, since I have to bind them to two different datagrids, one for TypeA and one for TypeB on different forms.

That's currently not possible.

Frans Bouma | Lead developer LLBLGen Pro
G.I.
User
Posts: 172
Joined: 09-Jun-2005
# Posted on: 10-Jun-2005 11:22:29   

Ok...so I think I will have to use one kind of entity with a type column. Then use this typecolumn for a filter and create two collections. After that I will have to use a order manager class to assign the correct orderline to each entity on both collections before saving them both...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 10-Jun-2005 11:50:23   

Correct.

Frans Bouma | Lead developer LLBLGen Pro