简体   繁体   English

SPMetal何时为查询字段生成EntityRef属性?

[英]When does SPMetal generate EntityRef properties for lookup fields?

I have a defined a content type called SPVideoDataItem containing those two fields: 我定义了一个名为SPVideoDataItem的内容类型, 其中包含这两个字段:

<Field ID="{487F2AD6-D9D6-47AA-AA99-B3FFF893E689}" Name="LUVideoQuality" Group="Custom Columns" Type="Lookup" DisplayName="Video Quality" List="Lists/GlobalVideoQualityList" ShowField="Title" PrependId="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE"/>
<Field ID="{F348A825-764D-41EE-AF92-8CF1DC246E47}" Name="LUVideoTitle" Group="Custom Columns" Type="Lookup" DisplayName="Video Title"  List="Lists/VideoItemList" ShowInEditForm="TRUE"  ShowInNewForm="TRUE" ShowField="VideoItemTitle" PrependId="TRUE" Required="TRUE"/>

For LUVideoQuality I get a property in a class called VideoItemDataListSPVideoDataItem : 对于LUVideoQuality,我在名为VideoItemDataListSPVideoDataItem的类中获得一个属性:

public SPVideoQualityItem VideoQuality

which exposes a EntityRef-Member, so I can access all properties of SPVideoQualityItem. 它公开了EntityRef-Member,因此我可以访问SPVideoQualityItem的所有属性。

However, for LUVideoTitle spmetal just generates two properties in the parent class SPVideoDataItem 但是,对于LUVideoTitle,spmetal只会在父类SPVideoDataItem中生成两个属性。

public string VideoTitleVideoItemTitle
public System.Nullable<int> VideoTitleId 

where I can only access title and ID. 我只能访问标题和ID。

I wonder why spmetal handles this two lookups differently. 我想知道为什么spmetal处理这两个查询的方式不同。 Can anyone explain this behaviour? 谁能解释这种行为? I would prefer that all lookups are handled like LUVideoQuality in my example. 在我的示例中,我希望所有查找都像LUVideoQuality一样进行处理。

I've encountered the same issue. 我遇到了同样的问题。

When I let go of the principle to create a separate content type and just created a list based on content type Item it did generate the entity refs. 当我放开创建单独的内容类型的原理并仅基于内容类型Item创建列表时,它确实会生成实体引用。

Apparently it has something to do with the "WebId" property of the lookup fields. 显然,它与查找字段的“ WebId”属性有关。 A colleague told me that they got it working by adding 一位同事告诉我,他们通过添加

WebId="~sitecollection" 

to all lookup fields in the content type definitions (Elements.xml). 内容类型定义(Elements.xml)中的所有查找字段。 Im not marking this as an answer because I did not check if it is working now because of this attribute or some other change in the definitions. 我没有将其标记为答案,因为由于该属性或定义中的某些其他更改,我没有检查它是否现在正在工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SPMetal 忽略农场解决方案中的查找列 - SPMetal ignores lookup columns in Farm Solution 使用SPMetal为Sharepoint中的网站集生成LINQ类 - Generate LINQ classes with SPMetal for Site Collection in Sharepoint 在SharePoint 2010中使用SPMetal由LoginName(ID)创建 - Created By LoginName (ID) with SPMetal in SharePoint 2010 到LINQ 2 Sharepoint Spmetal类的Sharepoint 2010 Listitem - Sharepoint 2010 listitem to linq 2 sharepoint spmetal class SharePoint 2010:使用SPMetal映射到图片超链接时出错 - SharePoint 2010: Error Mapping to Picture Hyperlink with SPMetal SPMetal不生成具有适当自定义类型的类。 将所有内容默认为“项目” - SPMetal not generating classes with proper custom types. Defaulting for everything to 'Item' 以编程方式生成的查找字段导致“System.ArgumentException:Value不在预期范围内”创建新项目时 - Programmatically generated Lookup Field causes “System.ArgumentException: Value does not fall within the expected range” when creating new item SharePoint 2010 NewForm.aspx查找字段问题 - SharePoint 2010 NewForm.aspx Lookup Fields Issue SPMetal:如何覆盖它以使用内部名称而不是“显示名称” - SPMetal: How to override it to use internal name instead of “Display Name” Sharepoint查找工作流程无法正常工作 - Sharepoint Lookup workflow does not work properly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM