Tanja,
The speed of EA is what it is.
How do those 14 seconds compare to opening the model using the EA client?
Building a full cached representation trough recursion is a BAD idea.
That will take ages.
What I do to cache my elements is use the Repository.GetElementSet.
If I need attributes, operations, or connectors then I first get a list of id's using Repository.SQLQuery and then get the item using the Repository.getXXXbyID operations.
Here's an example of my caching operation for elements for our SQL server repository. The same can be done with a local eap file, but then you'll have to rewrite the query to match to Access "SQL" syntax.
/// <summary>
/// adds all elements in the model to the cache
/// </summary>
public void addAllElementsToCache(string startingPackageID)
{
//first check if we are dealing with a local eap file in MS Access format.
//in that case we cannot perform the query with the unions
bool localEAPFile = true;
string connection = this.wrappedModel.ConnectionString;
if (connection.ToLower().EndsWith( ".eap"))
{
//could be an eap file, or could be a shortcut file.
//figure it out based on the size of the file
try
{
FileInfo connectionInfo = new FileInfo(connection);
if (connectionInfo.Length > 1000)
{
localEAPFile = true;
}
else
{
localEAPFile = false;
}
}catch (Exception)
{
localEAPFile = false;
}
}
Logger.log("start caching elements");
//build the sql string to get all the object fromthe starting package and 9 levels of packages underneath.
//there is a better way using a recursive query, but these are not supported in sql 2000 yet (only from sql 2005)
string sqlGetElements = @" SELECT o.Object_ID FROM t_object as o
left join t_package p on o.Package_ID = p.Package_ID
left join t_package p2 on p.Parent_ID = p2.Package_ID
left join t_package p3 on p2.Parent_ID = p3.Package_ID
left join t_package p4 on p3.Parent_ID = p4.Package_ID
left join t_package p5 on p4.Parent_ID = p5.Package_ID
left join t_package p6 on p5.Parent_ID = p6.Package_ID
left join t_package p7 on p6.Parent_ID = p7.Package_ID
left join t_package p8 on p7.Parent_ID = p8.Package_ID
left join t_package p9 on p8.Parent_ID = p9.Package_ID
where
p.package_ID = " + startingPackageID + @"
or p2.package_ID = " + startingPackageID + @"
or p3.package_ID = " + startingPackageID + @"
or p4.package_ID = " + startingPackageID + @"
or p5.package_ID = " + startingPackageID + @"
or p6.package_ID = " + startingPackageID + @"
or p7.package_ID = " + startingPackageID + @"
or p8.package_ID = " + startingPackageID + @"
or p9.package_ID = " + startingPackageID;
try
{
if (!localEAPFile)
{
//we only do caching when working on an remote database
EAWrapperFactory.createEAWrappers(this, this.wrappedModel.GetElementSet(sqlGetElements, 2));
}
Logger.log("end caching elements");
}
catch (Exception)
{
// oh well, caching failed, no biggy, we can work without caching, its just a bit slower
Logger.logError("Caching failed");
}
}