gpt4 book ai didi

c# - N2 内容管理系统 : Are nested collections of ContentItems possible?

转载 作者:行者123 更新时间:2023-11-30 15:46:00 26 4
gpt4 key购买 nike

可以将任意数量的同一类的 ContentItems 添加到 N2 中的页面吗?它们可以嵌套吗?

即有没有办法将 ContentItems 的集合定义为 N2 中的属性?如果可能的话,我还想嵌套这些,以便我们可以对数据运行更有意义的查询。 (即,而不是使用难以查询的巨大 EditableTextRegions。)

我目前有以下模型作为“理想”模型,它可以被 N2 化吗? (为清楚起见,我省略了属性和 N2 样式的 getter/setter)

public class Link : ContentItem
{
public string Text { get; set; }
public string Title { get; set; }
public string Url { get; set; }
}

public class Panel : ContentItem
{
public string Title { get; set; }
public string Text { get; set; }
public List<Link> Links { get; set; } // Should show an expandable number of “Link” editors in the CMS editor
public string ImageUrl { get; set; }
}

public class Page : ContentItem
{
public string Title { get; set; }
public string BodyText { get; set; }
public List<Panel> Panels { get; set; } // Should show an expandable number of “Panel” editors in the CMS editor
}

最佳答案

是的 - 在您的属性中使用 Get/SetDetailCollection 而不是 Get/SetDetail。

仅供引用,如果您使用的是 2.1,您可以将您的属性设置为 virtual 并取消 Get/SetDetail - 虽然不确定这是否适用于 DetailCollection 方法,但您可以将两者混合使用。

虽然我会小心你的建议 - 像这样嵌套集合可能会导致你 SELECT N+1下线的问题。如果您不能更改设计,那么我建议打开 N2 的数据库缓存(这只是 NH​​ibernate 的二级缓存),这种方式将尽可能多地保留在内存中,而不会过多地访问数据库。

关于c# - N2 内容管理系统 : Are nested collections of ContentItems possible?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4657357/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com