Hello again. I'm using SVN head, (rev 970). This time I included the patch as attachment.
Update didn't work for me, and I suspect, that occured because the generated class didn't contain any PK attributes. I used the debugger and stepped into the code. - While selecting a row, it is "registered" as an entity. - In function _GetOrRegisterEntity (in DbLinq/Data/Linq/DataContext.cs), the system tries to fetch the primary key. In my case, var identityKey remained null so: that row won't be tracked for changes (like the comment says...) - As a result of that: In DbLinq/Data/Linq/DataContext.SubmitChanges() was empty, so the function returned almost immediately without doing anything. My patch will attach IsPrimaryKey=true for all PK's and IsPrimaryKey=false for all other columns. This was good enough for me, but I can understand that my patch could use some improvements... Regards, George (from Holland, not from Texas :-) ) 2009/2/13 Pascal Craponne <[email protected]> > Hi George W (man, I speak to George W himself!), > The IsPrimaryKey identifies PKs only. And the update usually works. By > usually I mean "as far as I know". > What version do you use? Latest release or SVN head? > > Also, if you want your patch to be reviewed, please submit it as an > attachment. TortoiseSVN understand patches better than me and explains them > to me in a more human-readable way :) > > Pascal. > > jabber/gtalk: [email protected] > msn: [email protected] > > > > > On Fri, Feb 13, 2009 at 12:14, george_w <[email protected]> wrote: > >> >> 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 -~----------~----~----~----~------~----~------~--~---
DbLinq_AddPrimaryKeyAttribute.patch
Description: Binary data
