Table of Contents

Class DataMergeDefinition

Namespace
FluentCommand.Merge
Assembly
FluentCommand.SqlServer.dll

Represents the definition and configuration for a data merge operation, including target table, columns, and merge behavior.

public class DataMergeDefinition
Inheritance
DataMergeDefinition
Inherited Members

Constructors

DataMergeDefinition()

Initializes a new instance of the DataMergeDefinition class with default settings.

public DataMergeDefinition()

Remarks

By default, Columns is initialized as an empty list, TemporaryTable is generated with a unique name, IncludeInsert and IncludeUpdate are set to true, and Mode is set to Auto.

Properties

Columns

Gets or sets the collection of column mappings used in the merge operation.

public List<DataMergeColumn> Columns { get; set; }

Property Value

List<DataMergeColumn>

A list of DataMergeColumn instances representing the mapped columns.

IdentityInsert

Gets or sets a value indicating whether to allow identity insert on the TargetTable during the merge operation.

public bool IdentityInsert { get; set; }

Property Value

bool

true to allow identity insert; otherwise, false.

IncludeDelete

Gets or sets a value indicating whether to delete data from the TargetTable that is not found in the TemporaryTable.

public bool IncludeDelete { get; set; }

Property Value

bool

true to delete target data not present in the source data; otherwise, false.

IncludeInsert

Gets or sets a value indicating whether to insert data not found in the TargetTable.

public bool IncludeInsert { get; set; }

Property Value

bool

true to insert new data; otherwise, false. Default is true.

IncludeOutput

Gets or sets a value indicating whether to output the inserted, updated, or deleted values from the TargetTable after the merge operation.

public bool IncludeOutput { get; set; }

Property Value

bool

true to output the affected data; otherwise, false.

IncludeUpdate

Gets or sets a value indicating whether to update data found in the TargetTable.

public bool IncludeUpdate { get; set; }

Property Value

bool

true to update existing data; otherwise, false. Default is true.

Mode

Gets or sets the mode that determines how the merge operation will be processed.

public DataMergeMode Mode { get; set; }

Property Value

DataMergeMode

The DataMergeMode specifying the merge processing mode.

TargetTable

Gets or sets the name of the target table into which data will be merged.

public string TargetTable { get; set; }

Property Value

string

The name of the target table.

TemporaryTable

Gets or sets the name of the temporary table used for bulk inserting data before merging. If not set, a unique name is generated.

public string TemporaryTable { get; set; }

Property Value

string

The name of the temporary table for bulk insert operations.

Methods

AutoMap<TEntity>(DataMergeDefinition)

Automatically maps the properties of the specified entity type TEntity to the given DataMergeDefinition.

public static void AutoMap<TEntity>(DataMergeDefinition mergeDefinition)

Parameters

mergeDefinition DataMergeDefinition

The DataMergeDefinition to populate with mapped columns and table name.

Type Parameters

TEntity

The type of the entity to map.

Remarks

This method uses reflection to map entity properties to DataMergeColumn instances, setting key, insert, update, and ignore flags as appropriate.

Create<TEntity>()

Creates a new instance of DataMergeDefinition with properties automatically mapped from the specified entity type TEntity.

public static DataMergeDefinition Create<TEntity>()

Returns

DataMergeDefinition

A new DataMergeDefinition instance with columns and table name mapped from TEntity.

Type Parameters

TEntity

The type of the entity to auto-map.