Adds the dimension to the schema definition.
Syntax
Parameters
- dimension
- The dimension to add.
Return Value
A reference to this instance after the Add operation has completed.
Exceptions
| Exception | Description |
| System.ArgumentNullException | The dimension is a null reference (Nothing in Visual Basic). |
| System.ArgumentException | The dimension with the same name already exists in the SchemaBuilder. |
Example
The following code example demonstrates how to add the 'Order Date' dimension to the existing
SchemaBuilder.
| C# | Copy Code |
|---|
SchemaBuilder sb = new SchemaBuilder("My Name");
// ...
AttributeBuilder defaultField;
// Add attributes dimensions.
sb.AddDimension(
// Add dimension 'Order Date'.
new AttributesDimBuilder("Order Date")
.AddFields(
// Add hierarchy 'Order Date'
defaultField = 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")
)
,
// Add attribute 'Date'.
new AttributeBuilder("Date").SetExpression<DateTime>("=Fields!OrderDate.Value")
)
// Set 'Order Date' hierarchy as default field of 'Date' dimension.
.SetDefaultField(defaultField)
); |
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