CRM combines package

advertisements

I have two columnset object, how can I join their columns together into one object of type ColumnSet?

Dim col1 as new ColumnSet()
col1.AddColumn("column1")
col1.AddColumn("column2")

Dim col2 as new ColumnSet()
col2.AddColumn("column3")
col2.AddColumn("column4")

Crm4.0 .NET


C# Version:

ColumnSet column1 = new ColumnSet("name", "description");
ColumnSet column2 = new ColumnSet("name", "createdon");
ColumnSet merged = new ColumnSet((column1.Columns.Union(column2.Columns)).ToArray());

VB.NET version:

Dim column1 As New ColumnSet("name", "description")
Dim column2 As New ColumnSet("name", "createdon")
Dim merged As New ColumnSet((column1.Columns.Union(column2.Columns)).ToArray())

Union will take care of duplicated fields