m:1 m:1 fields mapped on related fields

Posts   
 
    
bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 26-Jun-2008 21:26:41   

llblgen v2.0 vs 2005 dotnet 2.0

I have the following tables and relationships bill m:1 batch batch m:1 batchstatus

Wishing to: I would like to create, in "fields mapped on related fields", bill.batchstatusname where batchstatusname is batchstatus.name.

Problem The bill does not have bill-batchstatus relation in the llblgen designer. Why is that?

Thank you

BZ

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Jun-2008 10:32:17   

In the designer only the following relations are recognized: 1:m m:1 1:1 m:n (via the intermediate table)

bill-batchstatus is not a 1:m, m:1 or m:n.

Anyway you can add the required property directly in the generated entity class. Better to add it in a partial class file, in order to be oreserved across code re-generations.

bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 27-Jun-2008 19:22:24   

Could any one please explain how come it is not supported (i.e. bill-batchstatus which really results in m:1 since bill-batch is m:1 and batch-batchstatus is m:1)? Each bill has a batchstatus uniquely defined so how come the relationship is not supported.

Thanks

arschr
User
Posts: 893
Joined: 14-Dec-2003
# Posted on: 27-Jun-2008 20:56:21   

Could any one please explain how come it is not supported (i.e. bill-batchstatus which really results in m:1 since bill-batch is m:1 and batch-batchstatus is m:1)? Each bill has a batchstatus uniquely defined so how come the relationship is not supported.

I can't say how come, but I'll try to explain what I think is the issue with an example from my database. I have: order charges -> order lines -> order -> Customer

Each -> is a m-1 relation. As I under stand your question. you are asking why order charges to orders and by implication why order charges to customers are not built for you automatically. I think the answer is that they are too far away, when would you stop? you could quickly have your whole database hanging as fields on each entity.

It is very easy to add a field in order charges to hold the customer (for example) using a partial class and to have that value available when you need it using prefetches.

bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 27-Jun-2008 21:59:13   

Check this out: 1. bill --m:1--> batch --m:1-->batchstatus is not allowed. 2. employer --n:m--> batch --m:1--> batchstatus is allowed.

In either case, you can have the chain "too far apart". Also, the designer can have just the relation available. The designer does not have to create the related fields. After all, the designer has "fields on related field" which allow the user to specify exactly what related fields that he wants.

I can see using partial class to add field. I just hope that these "added" fields show up in the gridview and formview wizard since I use databound control and llblgenprodatasource2 alot.

Thanks for the answer any how!

BTW, I know how to create fields for TypedList in partial class but I am not sure how to do this for Entity. Does any one has a reference or example or something. Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 28-Jun-2008 10:29:49   

bunzee wrote:

Check this out: 1. bill --m:1--> batch --m:1-->batchstatus is not allowed. 2. employer --n:m--> batch --m:1--> batchstatus is allowed.

What you want is a relation between two entities based on a chain of relations. The only relation type we support with that feature is an m:n relation (over two m:1 relations originating from the same intermediate entity). So, of course you can traverse the chain, but that's not a defined relation type.

In either case, you can have the chain "too far apart". Also, the designer can have just the relation available. The designer does not have to create the related fields. After all, the designer has "fields on related field" which allow the user to specify exactly what related fields that he wants.

The designer will show the relation bill-batch and the relation batch-batchstatus, it just won't allow the relation bill-batchstatus, as these entities don't have a relation of a known type. You can traverse from bill to batchstatus, but that's another topic.

Do you see the two relations in the designer?

I can see using partial class to add field. I just hope that these "added" fields show up in the gridview and formview wizard since I use databound control and llblgenprodatasource2 alot.

yes, any property you define will show up, unless you mark it with Browsable(false) then it is ignored. simple_smile

Frans Bouma | Lead developer LLBLGen Pro