Open GoogleCodeExporter opened 9 years ago
Someone created the following patch that seems to fix this issue. Just modify
the
files mentioned here in the src and compile. Enjoy
Index: src/DbMetal/Generator/CodeDomGenerator.cs
===================================================================
--- src/DbMetal/Generator/CodeDomGenerator.cs (revision 1408)
+++ src/DbMetal/Generator/CodeDomGenerator.cs (working copy)
@@ -879,7 +879,7 @@
CodeTypeMember CreateChangedMethodDecl(Column column)
{
- return CreatePartialMethod(GetChangedMethodName(column.Member));
+ return CreatePartialMethod(GetChangedMethodName(column.Member ??
column.Name));
}
static string GetChangingMethodName(string columnName)
@@ -889,7 +889,7 @@
CodeTypeMember CreateChangingMethodDecl(Column column)
{
- return CreatePartialMethod(GetChangingMethodName(column.Member),
+ return CreatePartialMethod(GetChangingMethodName(column.Member ??
column.Name),
new
CodeParameterDeclarationExpression(ToCodeTypeReference(column), "value"));
}
@@ -937,7 +937,7 @@
static string GetStorageFieldName(Column column)
{
- return GetStorageFieldName(column.Storage ?? column.Member);
+ return GetStorageFieldName(column.Storage ?? column.Member ??
column.Name);
}
static string GetStorageFieldName(string storage)
Index: src/DbMetal/Generator/Implementation/Processor.cs
===================================================================
--- src/DbMetal/Generator/Implementation/Processor.cs (revision 1408)
+++ src/DbMetal/Generator/Implementation/Processor.cs (working copy)
@@ -138,7 +138,7 @@
foreach (var association in table.Type.Associations)
{
var otherType = database.Tables.Single(t => t.Type.Name ==
association.Type).Type;
- var otherAssociation = otherType.Associations.Single(a =>
a.Type
== table.Type.Name && a.ThisKey == association.OtherKey);
+ var otherAssociation = otherType.Associations.Single(a =>
a.Type
== table.Type.Name && a.ThisKey == association.OtherKey && a.OtherKey ==
association.ThisKey);
var otherColumn = otherType.Columns.Single(c => c.Member ==
association.OtherKey);
if (association.CardinalitySpecified && association.Cardinality ==
Cardinality.Many && association.IsForeignKey)
Original comment by fama...@gmail.com
on 18 May 2010 at 3:34
I have verified this same bug against MySQL also. Please apply this fix to the
trunk!
Original comment by eric.bo...@gmail.com
on 30 Jun 2010 at 12:37
Based on fixing it myself (then finding this fix!) only the changes to
Processor.cs seem necessary. Not sure whether the CodeDomGenerator is need to
fix something else?
Original comment by cool...@gmail.com
on 8 Jul 2010 at 4:04
[deleted comment]
Initially I got the "Sequence contains more than one matching element" error.
Then, after I applied the above metioned patch/fix(I only made changes to
Processor.cs), I got another error "Sequence contains no matching elements".
Eventually I got it working(?), or at least to output a ".cs" file that
projects my database, by "commenting out" the following line(inside the same
foreach-loop as the previous fix).
(around line 135):
bool ValidateAssociations(Database database, Table table)
{
...
//var otherColumn = otherType.Columns.Single(c => c.Member ==
association.OtherKey);
...
}
Original comment by pmt.berg...@googlemail.com
on 1 Aug 2010 at 7:00
Original issue reported on code.google.com by
danspama...@gmail.com
on 4 May 2010 at 6:47