zengcheng / codesmith

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

Table called "Items" causes a problem with the CSLA templates #393

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a database containing a table called "Items". Add a second table, 
with a foreign key pointing back to the "Items" table.
2. Use the "QuickStart" template to generate a project.
3. Build the generated project.

What is the expected output? What do you see instead?
The "AddNewCore" method of the child class contains a local variable called 
"item" which is declared again later in the same method.

What version of the product are you using?
CSLA templates r1666
CodeSmith 5.2.1 rev 10970

Please provide any additional information below.

Generating Switchable Objects for all tables.

This code is from the ItemChildList.Generated.cs file:
-------------------------------------------------

 THIS VERSION (AS GENERATED) DOESN'T BUILD
        protected override object AddNewCore()
        {
            ItemChild item = Business.Models.ItemChild.NewItemChild();

            bool cancel = false;
            OnAddNewCore(ref item, ref cancel);
            if (!cancel)
            {
                // Check to see if someone set the item to null in the OnAddNewCore.
                if(item == null)
                    item = Business.Models.ItemChild.NewItemChild();

                // Pass the parent value down to the child.
                Item item = this.Parent as Item;
                if(item != null)
                    item.Item = item.Identification;

            }

            Add(item);
            return item;
        }

 THIS VERSION (MANUALLY MODIFIED) BUILDS
        protected override object AddNewCore()
        {
            ItemChild item = Business.Models.ItemChild.NewItemChild();

            bool cancel = false;
            OnAddNewCore(ref item, ref cancel);
            if (!cancel)
            {
                // Check to see if someone set the item to null in the OnAddNewCore.
                if(item == null)
                    item = Business.Models.ItemChild.NewItemChild();

                // Pass the parent value down to the child.
                Item item = this.Parent as Item;
                if(item != null)
                    item.Item = item.Identification;

            }

            Add(item);
            return item;
        }

--------------------------------------------------

Original issue reported on code.google.com by rlbrac...@gmail.com on 8 Jun 2010 at 8:10

GoogleCodeExporter commented 9 years ago
Hello,

This has been fixed in revision 1673.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 8 Jun 2010 at 8:51

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 21 Jun 2010 at 8:10