Jeff-Lewis / codesmith

Automatically exported from code.google.com/p/codesmith
0 stars 0 forks source link

PLINQO: Setting an EntityRef to null sets the wrong default value on the key #146

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have two tables with a foreign key relation, for instance Order and 
OrderLine, where OrderID in the OrderLine table is nullable
2. Generate the CSharp entities

What is the expected output? What do you see instead?
In Entity.Generated.cst, the following code is on line 339:
<%= info.AssignColumns[i].Storage %> = default(<%= 
GetColumnType(info.OtherColumns[i]) %>);

This means that setting the Order property of OrderLine to null will lead 
to the OrderID column of OrderLine being set to the default value of the 
OrderID column of Order, which is 0. This is wrong (and differs from the 
code generated by the standard LINQ to SQL designer). It should be set to 
its own default value, like this:
<%= info.AssignColumns[i].Storage %> = default(<%= GetColumnType(info. 
AssignColumns[i]) %>);

What version of the product are you using?
3.1.808

Please provide any additional information below.

Original issue reported on code.google.com by dasj...@gmail.com on 28 Sep 2009 at 8:53

GoogleCodeExporter commented 9 years ago
I confirmed this as a bug and fixed it.  Thank you for finding this and 
providing the
solution!  I've applied the patch and committed.

Original comment by paul.wel...@gmail.com on 28 Sep 2009 at 8:00

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 30 Dec 2009 at 5:43

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 30 Dec 2009 at 6:04

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 30 Dec 2009 at 9:16