ReUsing Custom Created Content Part

Topics: Core, Customizing Orchard
Jul 20, 2015 at 3:28 AM

I have a module called ModuleA which has custom contentParts created in MoudleA:

public class ProductPart : ContentPart<ProductPartRecord> {
    public string Model {
        get { return Record.Model; }
        set { Record.Model = value; }

    private readonly LazyField<MyBrandPartRecord> _brand = new LazyField<MyBrandPartRecord>();
    private readonly LazyField<MyProductCategoryPartRecord> _category = new LazyField<MyProductCategoryPartRecord>();

    public LazyField<MyBrandPartRecord> BrandPartField { get { return _brand;  } }
    public LazyField<MyProductCategoryPartRecord> ProductCategoryPartField { get { return _category; } }

    public MyBrandPartRecord Brand
        get { return _brand.Value; }
        set { _brand.Value = value; }

    public MyProductCategoryPartRecord Category
        get { return _category.Value; }
        set { _category.Value = value; }

public class ProductPartRecord : ContentPartRecord {
    public virtual string Model { get; set; }
    public virtual MyProductCategoryPartRecord productCategory { get; set; }
    public virtual MyBrandPartRecord brandCategory { get; set; }

    public virtual IList<ProductAttributeRecord> Attributes { get; set; }
MyBrandPart,MyProductCategoryPart are custom ContentParts along with ProductParts both created in ModuleA. Table (Products_ProductPartRecord) is created as

Id Model productCategory_Id brandCategory_Id

Now,I need to create another Module called "ModuleB" I need to store the ProductCategoryId as well as BrandCategory_Id like in Module A. Do I need to create the similar Content Part call "Equipment" in ModuleB like A and use it. Or is there a way to re use it in ModuleB.
Expected Table (Equipment_EquipmentPartRecord)
Id Model productCategory_Id brandCategory_Id

Any help will be appreciated.
Jul 20, 2015 at 10:15 AM
Just add a dependency in the module.txt:

dependencies: ModuleA

And add a reference to the moduleA project from within your moduleB project. Than you can just reuse the part.
Marked as answer by Kevinpiper123 on 7/20/2015 at 6:41 PM