ICustomMapping.MapFrom method

Assigns a field (column) to a property so that LINQ to SharePoint can read data from the field in the content database to the property that represents it.

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

void MapFrom(
	Object listItem


Type: System.Object

An Object that represents a list item and that can be cast to SPListItem.

Notes to implementers

This method must be decorated with a CustomMappingAttribute that assigns to its Columns property an array of the internal names of the new columns added to the list whose content type is represented by the class that is implementing ICustomMapping.

The following code shows a sample implementation of MapFrom(Object). In this example, the Books list (whose content type is Book) has new columns named ISBN and UPCA.

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.


Partial Public Class Book
    Implements ICustomMapping
    <CustomMapping(Columns := New String() { "ISBN", "UPCA" })>
    Public Sub MapFrom(ByVal listItem As Object)
        Dim item As SPListItem = CType(listItem, SPListItem)
        Me.ISBN = item("ISBN")
        Me.UPCA = item("UPCA")
    End Sub

    ' Other members omitted.

End Class