On Thu, 2010-08-19 at 08:03 -0700, sam wrote:
> What exactly is this code trying to check?
$ svn blame src/DbMetal/Generator/Implementation/Processor.cs
...
1391 jonmpryor bool ValidateAssociations(Database database,
Table table)
So it comes from r1391:
$ svn log src/DbMetal/Generator/Implementation/Processor.cs |
less
...look for r1391...
Fix Association Cardinality generation.
Our Association Cardinality was always wrong -- we'd generate
Cardinality.Many
for one association, and Cardinality.One for the reverse
association.
1. These need to match.
2. This mismatch was causing .NET SqlMetal to error out on
DbMetal-generated
.dbml files.
Instead of actually trying to deduce the correct value, do
what .NET SqlMetal
does: don't generate Cardinality at all.
Fixes Issue 228.
So this is to fix
http://code.google.com/p/dblinq2007/issues/detail?id=228
Basically, the .dbml file that DbMetal was generating was invalid, in
that attempting to use .NET SQLMETAL.EXE against a
DbMetal.exe-generated .dbml file resulted in a multitude of errors.
Our DBML was invalid, and I (in my infinite[0] wisdom) figured that the
solution was to validate the DBML to prevent it from being invalid.
As for why `otherAssociation` and `otherColumn` are there, if we're
going to verify that an association is correct we need the reverse
association, and the reverse column. That is, if A.FK is a FK
association referring to B.PK, we need to verify that B exists
(`otherType`), that B contains an association to A (`otherAssociation`,
because .dbml requires that associations be bidirectional), and that the
columns are correct.
Mostly we're verifying that things actually exist, though doubtless
something more user-friendly would be to use .SingleOrDefault() and use
Log.WriteErrorLine() if any of those lines return null.
> After tweaking the code to log an error, I discovered one table that
> had two identical associations, same PK and FK. Is that what this
> code is looking for?
Yup, among related errors.
- Jon
[0] Not actually infinite, and often completely lacking.
--
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en.