我有一个基于Sharepoint中的ContentType MyList
的列表MyContentType
。
现在我尝试使用SPMetal生成LINQ类,但ContentType的类基本上创建了两次。
SPMetal的XML配置
<?xml version="1.0" encoding="utf-8"?>
<Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">
<List Name="MyList">
<ContentType Name="MyContentType"></ContentType>
</List>
<ExcludeOtherLists/>
<ExcludeOtherContentTypes/>
</Web>
输出cs文件的部分
[Microsoft.SharePoint.Linq.ListAttribute(Name="MyList")]
public Microsoft.SharePoint.Linq.EntityList<MyContentTypeMyContentType> MyList {
get {
return this.GetList<MyContentTypeMyContentType>("MyList");
}
}
[...]
[Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="MyContentType", Id="0x01003D132021D84A48E9A16011B7648CBD98")]
[Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(MyContentTypeMyContentType))]
internal partial class MyContentType : Element {
[...]
}
[...]
[Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="MyContentType", Id="0x01003D132021D84A48E9A16011B7648CBD98", List="MyList")]
internal partial class MyContentTypeMyContentType : MyContentType {
public MyContentTypeMyContentType() {
this.OnCreated();
}
}
正如您所看到的,它会生成一个MyContentTypeMyContentType
来自MyContentType
的类。但为什么?这毫无用处。我该如何避免这种行为?
如果MyList
只是MyContentType
而不是MyContentTypeMyContentType
的实体列表,那么这是正确的。
PS
如果我在ContentType的XML配置中添加类名,如下所示:
<ContentType Name="MyContentType" class="MyContentType"></ContentType>
它仍会生成第二个类,并将其命名为MyContentType0
,这也是错误的。