orchardcms-1.9

How can I eager fetch content of custom types in a ContentManager query?

半世苍凉 提交于 2019-12-11 05:17:58
问题 I'm running into some n+1 performance issues when iterating over a collection of ContentItems of a custom Type that I created solely through migrations. ContentDefinitionManager.AlterPartDefinition("MyType", part => part .WithField("MyField", field => field ... ) ); ContentDefinitionManager.AlterTypeDefinition("MyType", type => type .WithPart("MyType") ); Every time I access a field of this part a new query is performed. I can use QueryHints to avoid this for the predefined parts var myItems

What is the proper way to add a Field to a custom Part in code?

徘徊边缘 提交于 2019-12-10 10:32:11
问题 There are several similar questions that sort of deal with this issue like this one or this one offering a pretty hacky solution. None of the ones out there have a clear satisfactory answer, or an answer at all, or are asking quite the same thing to begin with. Record public class MyPartRecord : ContentPartRecord { public virtual Boolean Property1 { get; set; } public virtual string Property2 { get; set; } } Part public class MyPart : ContentPart<MyPartRecord> { public Boolean Property1 { get

What is the proper way to add a Field to a custom Part in code?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 07:38:54
There are several similar questions that sort of deal with this issue like this one or this one offering a pretty hacky solution . None of the ones out there have a clear satisfactory answer, or an answer at all, or are asking quite the same thing to begin with. Record public class MyPartRecord : ContentPartRecord { public virtual Boolean Property1 { get; set; } public virtual string Property2 { get; set; } } Part public class MyPart : ContentPart<MyPartRecord> { public Boolean Property1 { get { return Record.Property1; } set { Record.Property1 = value; } } public string... } Migration