还原后 AMO 数据库对象不刷新
AMO Database object does not refresh after restore
amoServer.Restore(abfFile, db.Name, true);
amoServer.Databases.GetByName(db.Name).LastUpdate = db.LastUpdate;
我正在将一个 SSAS 数据库从一台服务器复制到另一台服务器。由于数据库正在恢复,最后一次更新已设置...所以我想将其更改回来。但是,似乎数据库集合永远不会使用新数据库进行更新。我在调用之前尝试了 .Refresh()
和 .Update()
,但我仍然收到错误
Microsoft.AnalysisServices.AmoException: The 'Database' with 'Name' =
'SomeReallyLongName' doesn't exist in the collection.
以前有人做过吗?
试试这个:
amoServer.Restore(abfFile, db.Name, true);
amoServer.Refresh(true, RefreshType.LoadedObjectsOnly);
Database dbRestore = amoServer.Databases.GetByName(db.Name);
dbRestore.LastUpdate = db.LastUpdate;
dbRestore.Update();
我不确定设置 LastUpdate 是否会如您所愿,但我怀疑您必须执行 .Update() 才能保存该更改。
amoServer.Restore(abfFile, db.Name, true);
amoServer.Databases.GetByName(db.Name).LastUpdate = db.LastUpdate;
我正在将一个 SSAS 数据库从一台服务器复制到另一台服务器。由于数据库正在恢复,最后一次更新已设置...所以我想将其更改回来。但是,似乎数据库集合永远不会使用新数据库进行更新。我在调用之前尝试了 .Refresh()
和 .Update()
,但我仍然收到错误
Microsoft.AnalysisServices.AmoException: The 'Database' with 'Name' = 'SomeReallyLongName' doesn't exist in the collection.
以前有人做过吗?
试试这个:
amoServer.Restore(abfFile, db.Name, true);
amoServer.Refresh(true, RefreshType.LoadedObjectsOnly);
Database dbRestore = amoServer.Databases.GetByName(db.Name);
dbRestore.LastUpdate = db.LastUpdate;
dbRestore.Update();
我不确定设置 LastUpdate 是否会如您所愿,但我怀疑您必须执行 .Update() 才能保存该更改。