Compartilhar via


ICustomMapping.Resolve Method

Resolves discrepancies in the values of one or more fields in a list item with respect to its current client value, its current value in the database, and its value when originally retrieved from the database.

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

Syntax

'Declaration
Sub Resolve ( _
    mode As RefreshMode, _
    originalListItem As Object, _
    databaseListItem As Object _
)
'Usage
Dim instance As ICustomMapping
Dim mode As RefreshMode
Dim originalListItem As Object
Dim databaseListItem As Object

instance.Resolve(mode, originalListItem, _
    databaseListItem)
void Resolve(
    RefreshMode mode,
    Object originalListItem,
    Object databaseListItem
)

Parameters

  • originalListItem
    Type: System.Object

    An object that represents the values of the list item when it was originally retrieved from the content database by the client item and that can be cast to SPListItem.

  • databaseListItem
    Type: System.Object

    An object that represents the current values of the list item in the database item and that can be cast to SPListItem.

Examples

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

public void Resolve(RefreshMode mode, object originalListObject, object databaseListObject)
{
    SPListItem originalListItem = (SPListItem)originalListObject;
    SPListItem databaseListItem = (SPListItem)databaseListObject;
           
    
    if ((mode == RefreshMode.OverwriteCurrentValues)
        ||
        ((mode == RefreshMode.KeepChanges) && (this == originalListItem)))
    
    {
        this.ISBN = databaseListItem["ISBN"];
        this.UPCA = databaseListItem["UPCA"];
    
    }
    else if (mode == RefreshMode.KeepChanges)
    {
        if (!(OriginalValues.Contains("ISBN")))
        {
            this.ISBN = databaseListItem["ISBN"];
        }
        
         if (!(OriginalValues.Contains("UPCA")))
        {
            this.UPCA = databaseListItem["UPCA"];
        }      
    }
} 
Public Sub Resolve(ByVal mode As RefreshMode, ByVal originalListObject As Object, ByVal databaseListObject As Object)
    Dim originalListItem As SPListItem = CType(originalListObject, SPListItem)
    Dim databaseListItem As SPListItem = CType(databaseListObject, SPListItem)


    If (mode = RefreshMode.OverwriteCurrentValues) OrElse ((mode = RefreshMode.KeepChanges) AndAlso (Me Is originalListItem)) Then

        Me.ISBN = databaseListItem("ISBN")
        Me.UPCA = databaseListItem("UPCA")

    ElseIf mode = RefreshMode.KeepChanges Then
        If Not(OriginalValues.Contains("ISBN")) Then
            Me.ISBN = databaseListItem("ISBN")
        End If

         If Not(OriginalValues.Contains("UPCA")) Then
            Me.UPCA = databaseListItem("UPCA")
         End If
    End If
End Sub

See Also

Reference

ICustomMapping Interface

ICustomMapping Members

Microsoft.SharePoint.Linq Namespace

Other Resources

Extending the Object-Relational Mapping