フィールドレスContentPartがContentItemに含まれていないのはなぜですか?
Migrations.csのコードは次のとおりです。
SchemaBuilder.CreateTable("ImageDescribedPartRecord",
table => table.ContentPartRecord());
ContentDefinitionManager.AlterPartDefinition(
"ImageDescribedPart",
cpd => cpd.WithField(
"Image",
b => b
.OfType("MediaPickerField")
.WithSetting("MediaPickerFieldSettings.Required", "false")));
ContentDefinitionManager.AlterTypeDefinition(
"PlantPicture",
cfg => cfg
.WithPart("ImageDescribedPart")
.WithPart("CommonPart", p => p.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false"))
.WithPart("BodyPart")
.WithPart("TitlePart")
.WithPart("AutoroutePart"
, builder =>
builder
.WithSetting("AutorouteSettings.AllowCustomPattern", "false")
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "true")
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Container', Pattern: '{Content.Container.Path}/images/{Content.Slug}', Description: 'apgii/taxon/sub-taxon/images/title'}]")
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
.WithPart("ContainablePart")
.Creatable(true)
// todo: The following doesn't work. Make it work.
.WithSetting("BodyPartSettings.FlavorDefault", "text")
);
ContentPartのコードは次のとおりです。
public class ImageDescribedPart : ContentPart<ImageDescribedPartRecord>{
}
public class ImageDescribedPartRecord :ContentPartRecord {}
ドライバーからの次のコード
IContentQuery<ContentItem> query = _contentManager
.Query(VersionOptions.Published)
.Join<CommonPartRecord>()
.Where(cr => cr.Container.Id == container.Id);
var items = query.Slice(0, 10).ToList();
IEnumerable<Zulatm.WebPlants.Models.ImageDescribedPart> firstImages = items.AsPart<ImageDescribedPart>();
Logger.Debug("Items count: {0}", items.Count());
for (int i = 0; i < items.Count(); i++) {
Logger.Debug("Item {0}: {1}", i, items[i].As<TitlePart>().Title);
}
Logger.Debug("Images count: {0}",firstImages.Count());
次を返します
2012-12-07 16:28:45,616 [35] TaxonomyNodePartDriver - Items count: 2
2012-12-07 16:28:45,617 [35] TaxonomyNodePartDriver - Item 0: Test
2012-12-07 16:28:45,619 [35] TaxonomyNodePartDriver - Item 1: test img 2
2012-12-07 16:28:45,619 [35] TaxonomyNodePartDriver - Images count: 0