sharepoint-2010lookuplinq-to-sharepoint

When does SPMetal generate EntityRef properties for lookup fields?


I have a defined a content type called SPVideoDataItem containing those two fields:

<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:

public SPVideoQualityItem VideoQuality

which exposes a EntityRef-Member, so I can access all properties of SPVideoQualityItem.

However, for LUVideoTitle spmetal just generates two properties in the parent class SPVideoDataItem

public string VideoTitleVideoItemTitle
public System.Nullable<int> VideoTitleId 

where I can only access title and ID.

I wonder why spmetal handles this two lookups differently. Can anyone explain this behaviour? I would prefer that all lookups are handled like LUVideoQuality in my example.


Solution

  • 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.