SPMetal 和 SharePoint 的 OOTB 博客网站模板

发布于 2024-12-01 12:41:49 字数 932 浏览 4 评论 0原文

我正在尝试创建一些工作流程和 Web 部件,以使用网站集中开箱即用的博客模板。我在普通博客网站上使用 SPMetal 来生成 LINQ 类和上下文,在编码时我注意到类别列表没有生成类。我认为没关系...因为 SharePoint 中的所有内容都是列表,我可以将列表指定为通用项目列表(类别仅在列表设置中列出标题、修改者等)。当我尝试查询列表并指出该列表不是项目的内容类型时,会出现此错误。

所以...真是无赖。我认为 SPMetal 的默认参数可能有问题。我创建了一个配置文件来与 SPMetal 一起运行...

<?xml version="1.0" encoding="utf-8"?>
<Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint2009/spmetal">
 <List Name="Categories">
  <ContentType Name="Item" Class="Categories" />
 </List>
</Web>

这在命令行中给出了一个错误,提示“错误:无法包含列表类别,因为它不包含从项目内容类型派生的内容类型。 现在我有点想知道这里的工作表下面到底发生了什么...我检查了博客站点模板中类别列表的 Schema.xml 并将其与帖子列表架构进行了比较.xml...Posts 有:

<ContentTypes>
 <ContentTypeRef ID="0x0110" />
</ContentTypes>

并且 Category 甚至根本没有 ContentTypes 节点。因此,我有点想修改类别的架构,并将该节点放在那里,指定 ID="0x01" 来强制它。 否则,如果其他人遇到过这个问题,我愿意接受建议。

谢谢!

I'm attempting to create some workflows and webparts to work with out of the box blog templates in a site collection. I used SPMetal against a normal blog site to generate the LINQ classes and contexts and while coding I noticed that the Categories list didn't have a class generated. I figure that's ok... since everything's a list in SharePoint I could just specify the list as a generic item list (Categories only has a Title, ModifiedBy, etc listed on the list settings). This errors out when I attempt to query the list saying the list isn't a content type of item.

So... bummer there. I figure maybe there's something wrong with the default parameters with SPMetal. I create an configuration file to run with the SPMetal...

<?xml version="1.0" encoding="utf-8"?>
<Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint2009/spmetal">
 <List Name="Categories">
  <ContentType Name="Item" Class="Categories" />
 </List>
</Web>

which gives me an error at the command line saying "Error: List Categories cannot be included because it does not contain a content type that derives from the Item content type.
Now I'm kind of in a state where I'm wondering what the hell is going on under the sheets here... I checked the Schema.xml for the Categories List in the Blog Site Template and compared that to the Posts List Schema.xml... Posts has:

<ContentTypes>
 <ContentTypeRef ID="0x0110" />
</ContentTypes>

and Categories does not have even have a ContentTypes node in it at all. So I am a bit tempted to just modify the schema for categories and put that node in there specifying the ID="0x01" to force it.
Otherwise I'm open to advice if anyone else has experience this problem.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文