See:
http://groups.google.com/group/dblinq/browse_thread/thread/a87d9293f6cc3717
/d244227c4b835ab3?
lnk=gst&q=invalid+code+produced+if+dbmetal#d244227c4b835ab3
What steps will reproduce the problem?
1. Create a table with more than one primary key.
2. Run DbMetal against the database.
What is the expected output? What do you see instead?
Valid C# code is expected.
Instead, we get:
public override int GetHashCode()
{
return _id1 == null ? 0 : _id1.GetHashCode() ^ _id2 == null ? 0 :
_id2.GetHashCode();
}
The simple fix is to modify line ~127 of CodeGenerator.Class.cs
from:
primaryKeyHashCode = writer.GetTernaryExpression(isNullExpression,
nullExpression, primaryKeyHashCode);
to something similar to the following:
primaryKeyHashCode = @"("
+
writer.GetTernaryExpression(isNullExpression, nullExpression,
primaryKeyHashCode)
+ @")";
This places a pair are parenthesis around the ternary expression and
solves the problem. The main code of GetTernaryExpression() in
CsCodeWriter.cs could also be fixed to do this instead if you think it
may be a better solution.
Original issue reported on code.google.com by jonmpr...@gmail.com on 23 Mar 2010 at 9:25
Original issue reported on code.google.com by
jonmpr...@gmail.com
on 23 Mar 2010 at 9:25