Databases Reference
In-Depth Information
FIGURE 34.8
The Update method populates a collection with the information about the
impact of removing an attribute from a dimension.
<Alter>
), except that it also contains an XML/A property,
ImpactAnalysis
, set to
1
. For a
review of impact analysis functionality as it is performed on the server, see Chapter 26.
Dependencies Calculator
To help the user understand the impact of deleting an object on other AMO objects, AMO
provides the
DependenciesCalculator
class. This class provides a client application with
the method
GetDeleteDependents
, which analyzes the database object passed by the client
code and the array of the objects to be deleted. It returns a
HashTable
containing
DependencyResult
objects that contain information about the dependencies. Each
DependencyResult
contains a dependent object, the type of dependency, and the descrip-
tion of the dependency. If you pass
TRUE
as a value of the
recursive
parameter, the
Dependencies Calculator recursively calculates dependencies over the dependent objects.
Let's take a look at an example of the use of the Dependencies Calculator. Code in Listing
34.3 retrieves AMO objects that will be affected by the deletion of the
Customers
hierarchy
from the database dimension
Customer
.
LISTING 34.3
Using the Dependencies Calculator
using (Server srv = new Server())
{
//Connect to a server.
srv.Connect(“localhost”);
//Choose the FoodMart 2008 database and Customer dimension.
Database db = srv.Databases.GetByName(“FoodMart 2008”);
Dimension dim = db.Dimensions.GetByName(“Customer”);
//Create DependenciesCalculator.
DependenciesCalculator dependsCalculator = new DependenciesCalculator();
//Analyze the objects affected by the deletion of the “Customers” hierarchy.
object[] objects = new object[] { dim.Hierarchies.GetByName(“Customers”) };
Hashtable dependencies = dependsCalculator.GetDeleteDependents(db, objects,
false);
Search WWH ::
Custom Search