Adds the field to the schema definition.
Syntax
Parameters
- field
- The field to add.
Return Value
A reference to this instance after the Add operation has completed.
Exceptions
| Exception | Description |
| System.ArgumentNullException | The field is a null reference (Nothing in Visual Basic). |
| System.ArgumentException | The field with the same name already exists in the dimension. |
Example
The following code example demonstrates how to add the 'Order Date' hierarchy to the existing
AttributesDimBuilder.
| C# | Copy Code |
|---|
AttributesDimBuilder dimBuilder = new AttributesDimBuilder("My Name");
// ...
dimBuilder
.AddField(
// Add hierarchy 'Order Date'
new HierarchyBuilder("Order Date")
// Add 3 levels: Year, Quarter and Month.
.AddLevels(
new LevelBuilder("Year").SetExpression<int>("=Fields!OrderDate_Year.Value"),
new LevelBuilder("Quarter")
.SetExpression<int>("=Fields!OrderDate_Quarter.Value")
// Set caption like 'Q1 2008'
.SetCaptionExpression(
"=\"Q\" & Fields!OrderDate_Quarter.Value & \" \" & Fields!OrderDate_Year.Value")
,
new LevelBuilder("Month")
.SetExpression<int>("=Fields!OrderDate_Month.Value")
// Set caption like 'June, 2008'
.SetCaptionExpression(
"=MonthName(Fields!OrderDate_Month.Value) & \", \" & Fields!OrderDate_Year.Value")
)
); |
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also