[英]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.