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)


Sub MapFrom ( _
    listItem As Object _
Dim instance As ICustomMapping
Dim listItem As Object

void MapFrom(
    Object listItem



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

See Also


ICustomMapping Interface

ICustomMapping Members

Microsoft.SharePoint.Linq Namespace

Other Resources

Extending the Object-Relational Mapping