Compartilhar via


CustomMappingAttribute.Columns Property

Gets or sets the internal names of columns that need to be retrieved from the content database and mapped to a property in a class that represents a content type.

Namespace:  Microsoft.SharePoint.Linq
Assembly:  Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)

Syntax

'Declaration
Public Property Columns As String()
    Get
    Set
'Usage
Dim instance As CustomMappingAttribute
Dim value As String()

value = instance.Columns

instance.Columns = value
public string[] Columns { get; set; }

Property Value

Type: []
An array of Strings that identify the columns by their internal names or an array consisting of a single element; the string “*”.

Remarks

If you construct the array with a single string consisting of an asterisk “*”, then all fields in the content type are fetched and all properties of the SPListItem object are also fetched. This can be useful when you need your solution to work with lists on which end users may have added new columns after your solution is deployed or if you need to map properties other than the fields of the content type. For more information about this scenario, see Extending the Object-Relational Mapping.

Examples

The following example shows how the Columns property of the CustomMappingAttribute is used on the MapFrom(Object) method.

public partial class Book : ICustomMapping
{
    [CustomMapping(Columns = new String[] { "ISBN", "UPCA" })]
    public void MapFrom(object listItem)
    {
        SPListItem item = (SPListItem)listItem;
        this.ISBN = item["ISBN"];
        this.UPCA = item["UPCA"];
    }

    // Other members omitted.

}

See Also

Reference

CustomMappingAttribute Class

CustomMappingAttribute Members

Microsoft.SharePoint.Linq Namespace