Hello all.

Today I dived in and tried to use DbLinq to manipulate a MySQL
database..

I ran into two problems:
1: the generated code failed to compile. The attribute "AutoGenId"
wasn't recognised. I read that this attribute was deprecated, so I
removed the corresponding code in DbMetal

2. records weren't updated when I called db.SubmitChanges()
The C# class file, generated from my database schema, didn't include
any primary key column attributes.

So, I debugged DbMetal (as I understand that VisualMetal isn't
maintained), and I patched it, so the "IsPrimaryKey" attribute is
included with every column.

If my patch is correct, can it be committed into the repository?

If it isn't correct, can anyone tell me how to get the primary key
attribute into the generated C# class properly?


Regards,

George

=======================


Index: src/DbMetal/Generator/Implementation/CodeDomGenerator/
AbstractCodeDomGenerator.cs
===================================================================
--- src/DbMetal/Generator/Implementation/CodeDomGenerator/
AbstractCodeDomGenerator.cs     (revision 970)
+++ src/DbMetal/Generator/Implementation/CodeDomGenerator/
AbstractCodeDomGenerator.cs     (working copy)
@@ -214,8 +214,6 @@
                 var columnMember = column.Member ?? column.Name;

                 var field = new CodeMemberField(type, "_" +
columnMember);
-                if (column.IsDbGenerated)
-                    field.CustomAttributes.Add(new
CodeAttributeDeclaration("AutoGenId"));
                 _class.Members.Add(field);
                 var fieldReference = new CodeFieldReferenceExpression
(new CodeThisReferenceExpression(), field.Name);

@@ -237,7 +235,8 @@
                         new CodeAttributeArgument("Storage", new
CodePrimitiveExpression(column.Storage)),
                         new CodeAttributeArgument("Name", new
CodePrimitiveExpression(column.Name)),
                         new CodeAttributeArgument("DbType", new
CodePrimitiveExpression(column.DbType)),
-                        new CodeAttributeArgument("CanBeNull", new
CodePrimitiveExpression(column.CanBeNull))
+                        new CodeAttributeArgument("CanBeNull", new
CodePrimitiveExpression(column.CanBeNull)),
+                        new CodeAttributeArgument("IsPrimaryKey", new
CodePrimitiveExpression(column.IsPrimaryKey))
                         )
                     );
                 property.CustomAttributes.Add(new
CodeAttributeDeclaration("DebuggerNonUserCode"));


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to