CustomMappingAttribute Class
Identifies what new columns are mapped with the MapFrom(Object) method that is decorated with the attribute.
Inheritance Hierarchy
System.Object
System.Attribute
Microsoft.SharePoint.Linq.CustomMappingAttribute
Namespace: Microsoft.SharePoint.Linq
Assembly: Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple := False)> _
Public NotInheritable Class CustomMappingAttribute _
Inherits Attribute
'Usage
Dim instance As CustomMappingAttribute
[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = false)]
public sealed class CustomMappingAttribute : Attribute
Remarks
You can also map properties to particular hashtable entries in the SPListItem.Properties property bag.
Examples
The following example shows how CustomMappingAttribute is used on the MapFrom(Object) method.
Note
Although the mapping applies to the MapTo(Object) method as well, only the MapFrom(Object) method is decorated with the attribute.
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.
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.