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)

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 “*”.

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.

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.