Table of Contents

Class TargetItem<TEntity>

Namespace
Hsl.Xrm.Sdk
Assembly
Hsl.Xrm.Sdk.Core.dll
public class TargetItem<TEntity> : ITargetItem<TEntity>, ITargetItem where TEntity : Entity

Type Parameters

TEntity
Inheritance
TargetItem<TEntity>
Implements
ITargetItem<TEntity>
Inherited Members

Constructors

TargetItem(Entity, Entity?, Entity?, int, int, bool)

Creates a new TargetItem instance.

public TargetItem(Entity target, Entity? preImage, Entity? postImage, int index, int count, bool isCreate)

Parameters

target Entity

The main target of the operation

preImage Entity

The preimage, if available

postImage Entity

The postimage, if available

index int

The index for the order of the records in this message

count int

The number of records in this message

isCreate bool

Whether the operation is a create message

TargetItem(Entity, int, int, bool)

Creates a new TargetItem instance when creating outside of a plugin context.

public TargetItem(Entity target, int index, int count, bool isCreate)

Parameters

target Entity

The main target of the operation

index int

The index for the order of the records in this message

count int

The number of records in this message

isCreate bool

Whether the operation is a create message

Properties

Id

Primary id of the record

public Guid Id { get; }

Property Value

Guid

Index

The index of this record within the bulk operation

public int Index { get; }

Property Value

int

Input

public TEntity Input { get; }

Property Value

TEntity

this[string]

Get the expected value of the field after the operation checking data in the postimage, target, then preimage (if available). OR sets a value to the target input record.

public object? this[string attribute] { get; set; }

Parameters

attribute string

The logical name of the attribute.

Property Value

object

Value of the given attribute

ItemIdentifier

Text that can be put at the front of log or error messages indicating which record is being processed.

public string ItemIdentifier { get; }

Property Value

string

LogicalName

The logical name of the record table

public string LogicalName { get; }

Property Value

string

Merged

public TEntity Merged { get; }

Property Value

TEntity

PostImage

public TEntity? PostImage { get; }

Property Value

TEntity

PreImage

public TEntity? PreImage { get; }

Property Value

TEntity

Methods

CreateException(string, Exception?)

public InvalidPluginExecutionException CreateException(string message, Exception? innerException = null)

Parameters

message string
innerException Exception

Returns

InvalidPluginExecutionException

GetValue<T>(string)

Get the expected value of the field after the operation checking data in the postimage, target, then preimage (if available).

public T? GetValue<T>(string attribute)

Parameters

attribute string

The logical name of the attribute to get

Returns

T

Value of the attribute

Type Parameters

T

Type of the attribute to get

IsFieldChanged(string)

Whether the attribute has a different value between the target input and the preimage. Always returns true for create operations.

public bool IsFieldChanged(string attribute)

Parameters

attribute string

The logical name of the attribute to check

Returns

bool

Whether the attribute was changed.