CustomMappingAttribute 类

标识哪些新的列映射用特性修饰的MapFrom(Object)方法。

继承层次结构

System.Object
  System.Attribute
    Microsoft.SharePoint.Linq.CustomMappingAttribute

命名空间:  Microsoft.SharePoint.Linq
程序集:  Microsoft.SharePoint.Linq(位于 Microsoft.SharePoint.Linq.dll 中)

语法

声明
<AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple := False)> _
Public NotInheritable Class CustomMappingAttribute _
    Inherits Attribute
用法
Dim instance As CustomMappingAttribute
[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = false)]
public sealed class CustomMappingAttribute : Attribute

备注

您还可以将属性映射到特定的哈希表条目SPListItem.Properties属性包中。

示例

下面的示例演示如何使用CustomMappingAttribute的MapFrom(Object)方法。

备注

尽管映射应用于该的MapTo(Object)方法,只有MapFrom(Object)方法是用特性修饰。

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.

}

线程安全性

该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。

另请参阅

引用

CustomMappingAttribute 成员

Microsoft.SharePoint.Linq 命名空间