Orchardcms Orchard CMS:ContentPart未在迁移中添加到ContentItem

Orchardcms Orchard CMS:ContentPart未在迁移中添加到ContentItem,orchardcms,orchardcms-1.8,Orchardcms,Orchardcms 1.8,我正在尝试在迁移中构建具有以下内容的模块: public class XyzzyPartRecord : ContentPartRecord { public virtual string Plugh { get; set; } } public class XyzzyPart : ContentPart<XyzzyPartRecord> { public string Plugh {

我正在尝试在迁移中构建具有以下内容的模块:

    public class XyzzyPartRecord : ContentPartRecord
    {
        public virtual string Plugh { get; set; }
    }

    public class XyzzyPart : ContentPart<XyzzyPartRecord>
    {
        public string Plugh {
            get { return Retrieve( r => r.Plugh ); }
            set { Store( r => r.Plugh, value ); }
        }
    }

    public int Create() {

        SchemaBuilder.CreateTable( "XyzzyPartRecord", table => table
            .ContentPartRecord()
            .Column<string>( "Plugh" )
        );

        ContentDefinitionManager.AlterPartDefinition( "XyzzyPart", cfg => cfg
            .WithDescription( "XyzzyPart" ) );

        ContentDefinitionManager.AlterTypeDefinition( "XyzzyItem", cfg => cfg
            .WithPart( "XyzzyPart" )
        );

        return 1;
    }
公共类XyzzyPartRecord:ContentPartRecord
{
公共虚拟字符串Plugh{get;set;}
}
公共类XyzzyPart:内容部分
{
公共字符串插件{
获取{return Retrieve(r=>r.Plugh);}
集合{Store(r=>r.Plugh,value);}
}
}
公共int创建(){
CreateTable(“XyzzyPartRecord”,table=>table
.ContentPartRecord()
.栏(“Plugh”)
);
ContentDefinitionManager.AlterPartDefinition(“XyzzyPart”,cfg=>cfg
.附说明(“XyzzyPart”);
ContentDefinitionManager.AlterTypeDefinition(“xyzyItem”,cfg=>cfg
.带部分(“XyzzyPart”)
);
返回1;
}
访问XyzzyItem时,零件集合中没有XyzzyPart。取而代之的是内容部分


如何获取我的内容部件以允许将其添加到内容项的部件集合中?

我忽略了为我的部件创建驱动程序或处理程序。一旦这些都到位了,我的代码就按预期工作了

namespace MyProject.Drivers {

    public class XyzzyPartDriver : ContentPartDriver<XyzzyPart> {

        protected override DriverResult Display( XyzzyPart part, string displayType, dynamic shapeHelper ) {
            return ContentShape( "Parts_Xyzzy",
                () => shapeHelper.Parts_Xyzzy(
                    Xyzzy: part ) );
        }
    }
}

namespace MyProject.Handlers {

    public class XyzzyPartHandler : ContentHandler {

        public XyzzyPartHandler( IRepository<XyzzyPartRecord> repository ) {
            Filters.Add( StorageFilter.For( repository ) );
        }
    }
}
名称空间MyProject.Drivers{
公共类XyzzyPartDriver:ContentPartDriver{
受保护的替代驱动器结果显示(XyzzyPart部件、字符串显示类型、动态形状帮助){
返回ContentShape(“Parts_xyzy”,
()=>shapeHelper.Parts\u xyzy(
xyzy:部分);
}
}
}
名称空间MyProject.Handlers{
公共类XyzzyPartHandler:ContentHandler{
公共XyzzyPartHandler(IRepository存储库){
Filters.Add(StorageFilter.For(repository));
}
}
}

在迁移运行完成之前,不应尝试创建刚创建的类型的项。通常,迁移不是创建内容的正确位置。食谱是应该做的。我编辑了这个问题,以更好地反映我所面临的问题。