jonpryor / dblinq2007

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

exception when 2 foreign keys on a table point to the same fiel on another table #280

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a table
2. create 1:n assosiation from that table to itself using another table

like 
Table A (ID, Text)
and now a row in a is related to several rows in A.
I did that with a new Table

Table B (IDSource, IDRelated)
where IDSource is a FK to A.ID and IDReleated is a FK to A.ID

3.run dbmetal on that database

What is the expected output? What do you see instead?
a .cs file  got exception

What version of the product are you using? On what operating system?
using latest dblinq 0.20.1 on windows7 64 bit

Please provide any additional information below.
crash occurs in Processor.cs line 141;

i changed the code to:
var otherAssociation    = otherType.Associations.Where(a => a.Type == 
table.Type.Name && a.ThisKey == association.OtherKey).First<Association>();

it created the cs file now, but i didnt test it yet.

for further questions plz contact me using feanzi[at]yahoo.de as mail address

Original issue reported on code.google.com by danja...@googlemail.com on 25 Aug 2010 at 9:45

GoogleCodeExporter commented 9 years ago
May be this version of code line is better:
 var otherAssociation    = otherType.Associations.Single(a => a.Type == table.Type.Name && a.ThisKey == association.OtherKey && a.OtherKey == association.ThisKey);
Now association selected by table name, destination column and source column. 
In your example FK matches by 2 first conditions.

Original comment by Goroh...@gmail.com on 9 Apr 2013 at 3:14