tags:

views:

47

answers:

2

i've inherited a project that is using subsonic. I wish to extend the OrderItem class with a new property "ProductType".

I am able to add the following. But as this a sub directory of /generated/ i'm obviously feeling like i'm missing a trick here. Do i need some kind of BAT file.

  [XmlAttribute("ProductType")]
    public string ProductType
    {
        get { return GetColumnValue<string>(Columns.ProductType); }

        set { SetColumnValue(Columns.ProductType, value); }

    }
+2  A: 

You should use a partial class to do this. See the following answer for an example:

http://stackoverflow.com/questions/1480286/adding-properties-to-an-existing-object-retreived-using-subsonic/1481772#1481772

Adam
i'm sure the answer is contain in that post. How does code generation in subsonic work. I've done the temporary hack in my post above, but my new values are not being initialised.
frosty
Which version of SubSonic is your project using?
Adam
+1  A: 

You don't want to change the code generated stuff - it will get overwritten. Instead add a partial as Adam suggests.

The code generation works using T4 templates - right click and "Run Custom Control" and it just runs:

http://subsonicproject.com/docs/T4%5FTemplates

Rob Conery