Searching a way to extend a xxxPartRecord without updading the original classes code

Topics: Customizing Orchard, Writing modules
Mar 14, 2013 at 1:32 PM
I want to add a property to a Part created by another module but I don't want to change the module source code.

OrigPartRecord and OrigPart classes created in the Model folder of module x.

My module is an extender of module x.

I can managed to add the column by code in my module migration file suing something like this
            Func<string, string> formatPrefix= (s => s.Replace(".", "_") + "_");
            var newSchemaB= new SchemaBuilder(_interpreter, "Nwazet.Commerce", formatPrefix);
            newSchemaB.AlterTable("ProductPartRecord", table => table
                        .AddColumn("MinimumOrderQuantity", DbType.Int32));
But I can't find a way to have NHibernate taking care of this new property.
If I try to create my own classes which inherit from the former classes, I get errors.

May be somebody has already dealed with this or could recommand a positive approch ?
Mar 14, 2013 at 2:47 PM
Edited Mar 14, 2013 at 2:48 PM
Ok I have a 'business' turn around using a new Part, but the problem still exists: without changing the code, it is impossible to extend an Orchard Part. ?

Working on common Orchard projects mean changing the code... even if i have read some versioning voluntee in some posts.
Mar 14, 2013 at 5:24 PM
You could remove the original part and attach your custom part, perhaps you could even derive it from the original part. Just be sure to implement a driver (possibly inherited as well).
Mar 14, 2013 at 5:25 PM
No no no no no. You're dooinitrong. Inheritance is not the right way to do this. If you want to add a property to an existing part record, you add a property to the existing part record. If you don't want to touch that part, you add a new one. Orchard works by composition, not inheritance.
Mar 14, 2013 at 5:32 PM
That is actually what I wanted to say initially: just create a new part and remove the other one if you don't want it. You're right, forget what I said about trying to inherit. I'm inheriting bad ideas here ;)