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)
Syntax
'Declaration
Sub MapFrom ( _
listItem As Object _
)
'Usage
Dim instance As ICustomMapping
Dim listItem As Object
instance.MapFrom(listItem)
void MapFrom(
Object listItem
)
Parameters
listItem
Type: System.ObjectAn Object that represents a list item and that can be cast to SPListItem.
Remarks
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.
Examples
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
Reference
Microsoft.SharePoint.Linq Namespace