|
List Relationships in SharePoint 2010
SPQuery Class
列出联接和投影
SharePoint 2010: using SPQuery Joins and ProjectedFields
Using join with CAML in SharePoint development
SPQuery.ProjectedFields Property
The following example shows how to add another field to the results that are returned by the query. The value of the List attribute is an alias to the foreign list. The alias is defined in a Join Element (View). The ShowField attribute must be set to the internal name of the foreign field.
The Type attribute does not indicate the data type of the field as it usually does in a Field element. When a Field element is a child of a ProjectedFields element, Type simply indicates whether the Join element (in the Joins element on which the ProjectedFields element depends) is based on an existing lookup relation between the lists. As of SharePoint Foundation 2010, all joins must be based on an existing lookup relation, so Type always has the value “Lookup”. The actual data type of the field is not indicated when it is a child of the ProjectedFields element. However, the field’s data type does matter because only the following types of fields can be included in a ProjectedFields element:
- Calculated (treated as plain text)
- ContentTypeId
- Counter
- Currency
- DateTime
- Guid
- Integer
- Note (one-line only)
- Number
- Text
<ProjectedFields>
<Field
Name=’CustomerCity’
Type=’Lookup’
List=’customerCities’
ShowField=’Title’ />
</ProjectedFields> |
|