TXTextControl.DocumentServer.MailMerge.MergeObjects Method

Merges a collection of type System.Collections.IEnumerable containing objects of any type or instances of type System.Collections.Generic.Dictionary with string keys into the loaded document template.

Introduced: 20.0.

MergeObjects(IEnumerable, Boolean)

Interprets all public properties of the objects or the key names of the dictionaries in the collection as possible table columns and / or child tables. The type of the first object (or the key names and types of the first dictionary) in the collection is analyzed via .NET reflection and used as the basis of the assumed table structure. (In case of the collection containing objects of different types, the merge process is successful nevertheless, but some fields will be empty.) Properties of simple data types (e. g. string, int, enum) are converted to text using the ToString method. The textual representation of enum values can be specified using the System.ComponentModel.DescriptionAttribute. (For example: enum FoodCategory { [Description("Grains / Cereals")] Grains_Cereals, ... }.) The name by which Properties are mapped to field names can be adjusted using the System.ComponentModel.DisplayNameAttribute. (For example: [DisplayName("Name")] public string ProductName { get; set; }.) Complex properties which are themselves of type System.Collections.IEnumerable are interpreted as child Tables and used for merging merge blocks and nested merge blocks. This way data relations can be represented. Properties of a type itself having public properties are either interpreted as a simple table column (the merged text then is determined using the ToString() method) or they are treated as if they were a child table containing only one data row with the properties being the table columns. The second parameter specifies whether the single documents should be merged into one document or split into separate documents. The supported format of the merge fields can be found in the ASP.NET User's Guide.

[C#]
public void MergeObjects(System.Collections.IEnumerable mergeData, bool append);
[Visual Basic]
Public Sub MergeObjects(ByVal mergeData As System.Collections.IEnumerable, ByVal append As Boolean)
Parameter Description
mergeData

Specifies a System.Collections.IEnumerable that contains the merge data.

append

Specifies whether the single documents should be merged into one document or split into separate documents.

MergeObjects(IEnumerable)

Does the same as MergeObjects with the parameter “append” set to true.

[C#]
public void MergeObjects(System.Collections.IEnumerable mergeData);
[Visual Basic]
Public Sub MergeObjects(ByVal mergeData As System.Collections.IEnumerable)
Parameter Description
mergeData

Specifies a System.Collections.IEnumerable that contains the merge data.

See Also