Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ICustomMapping.MapTo method

Assigns a property to a field (column) so that LINQ to SharePoint can save the value of the property to the field in the content database.

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

void MapTo(
	Object listItem
)

Parameters

listItem
Type: System.Object

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

Notes to implementers

Do not decorate this method with a CustomMappingAttribute.

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


public partial class Book : ICustomMapping
{
    public void MapTo(object listItem)
    {
        SPListItem item = (SPListItem)listItem;
        item["ISBN"] = this.ISBN;
        item["UPCA"] = this.UPCA;
    }

    // Other members omitted.

}

Partial Public Class Book
    Implements ICustomMapping
    Public Sub MapTo(ByVal listItem As Object)
        Dim item As SPListItem = CType(listItem, SPListItem)
        item("ISBN") = Me.ISBN
        item("UPCA") = Me.UPCA
    End Sub

    ' Other members omitted.

End Class
Show:
© 2015 Microsoft