Jeff-Lewis / codesmith

Automatically exported from code.google.com/p/codesmith
0 stars 0 forks source link

one to many to many association, the second association generation is wrong #119

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. three table, 
   a. Orders            one
   b. OrderLines        many , cascade delete with orders delete
   c. OrderLineDetails  
      OrderLines -> OrderLineDetails, one to many relations.
   when we delete one line in orders, should cascade delete orderlines and 
orderlinedetails. when we delete one line in orderlines, should cascade 
delete orderlinedetails.
2. Generate entity.
3. The association that your template generate would be:
    Orders generate: (this is correct)
    [Association(Name="Orders_OrderLines", Storage="_orderlinesList", 
ThisKey="OrderID", OtherKey="OrderID")]
        public EntitySet<orderLines> orderLinesList
        {
            get { return _orderLinesList; }
            set { _orderLinesList.Assign(value); }
        }
    OrderLines generate: (this is wrong)
    [Association(Name="orders_orderlines", Storage="_orders", 
ThisKey="OrderID", OtherKey="OrderID", IsUnique=true, IsForeignKey=true, 
DeleteRule="CASCADE")]

    We hope that it would be something like the third layer
    [Association(Name="orderlines_orderlinedetails", 
Storage="_orderlines", ThisKey="OrderLineID", OtherKey="OrderLineID", 
IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")]

    We don't need the "isUnique=true", and need the "DeleteOnNull=true"

    so that when you delete one line in orderline, and click submitchanges,
you will not get an error.

My template version is: plinqo-v3.0.687

What is the expected output? What do you see instead?
expected output:
[Association(Name="orders_orderlines", Storage="_orders", 
ThisKey="OrderID", OtherKey="OrderID", DeleteOnNull=true, 
IsForeignKey=true, DeleteRule="CASCADE")]

we see instead:
[Association(Name="orders_orderlines", Storage="_orders", 
ThisKey="OrderID", OtherKey="OrderID", IsUnique=true, IsForeignKey=true, 
DeleteRule="CASCADE")]

Please use labels and text to provide additional information.

Original issue reported on code.google.com by changchu...@gmail.com on 5 Aug 2009 at 9:42

GoogleCodeExporter commented 9 years ago
Hi, I don't think this scenario is consider a true many to many relationship.  
I will 
investigate it further. 

Original comment by paul.wel...@gmail.com on 11 Aug 2009 at 2:05

GoogleCodeExporter commented 9 years ago
What I mean is 
Table A - Table B    One - Many (Cascade update/delete)
Table B - Table C    One - Many (Cascade update/delete)

and Then I call it One to many to many.

Original comment by changchu...@gmail.com on 15 Aug 2009 at 3:01

GoogleCodeExporter commented 9 years ago
LINQ to SQL doesn't support this scenario therefore PLINQO will not be able to. 

Original comment by shannon....@gmail.com on 28 Aug 2009 at 4:17

GoogleCodeExporter commented 9 years ago
Linq to SQL support this scenario.
When generate with microsoft designer.
the code as follow,
Association in Table B
<Association(Name:="TableA_TableB", Storage:="_TableA", ThisKey:="TableAID", 
OtherKey:="TableAID", IsForeignKey:=true, DeleteOnNull:=true, 
DeleteRule:="CASCADE")>
Association in Table C
<Association(Name:="TableB_TableC", Storage:="_TableB", ThisKey:="TableBID", 
OtherKey:="TableBID", IsForeignKey:=true, DeleteOnNull:=true, 
DeleteRule:="CASCADE")>

And PLINQO will generate like

Association in Table B
<Association(Name:="TableA_TableB", Storage:="_TableA", ThisKey:="TableAID", 
OtherKey:="TableAID", IsForeignKey:=true, isUnique:=true, 
DeleteRule:="CASCADE")>
Association in Table C
<Association(Name:="TableB_TableC", Storage:="_TableB", ThisKey:="TableBID", 
OtherKey:="TableBID", IsForeignKey:=true, DeleteOnNull:=true, 
DeleteRule:="CASCADE")>

The difference is within accociaion in table B:
PLINQO use "isUnique" instead of "deleteonnull"

Please check and have a comment, thanks.

Original comment by changchu...@gmail.com on 29 Aug 2009 at 1:04