当前位置: 首页>>代码示例>>C#>>正文


C# SessionBase.OpenDatabase方法代码示例

本文整理汇总了C#中SessionBase.OpenDatabase方法的典型用法代码示例。如果您正苦于以下问题:C# SessionBase.OpenDatabase方法的具体用法?C# SessionBase.OpenDatabase怎么用?C# SessionBase.OpenDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionBase的用法示例。


在下文中一共展示了SessionBase.OpenDatabase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loadCities

 void loadCities(SessionBase session)
 {
   Database db = session.OpenDatabase(session.DatabaseNumberOf(typeof(City)));
   if (db != null)
   {
     var src = from City city in db.AllObjects<City>() select city;
     CityName.ItemsSource = src;
     Country.ItemsSource = src;
     Latitude.ItemsSource = src;
     Longitude.ItemsSource = src;
     //State.ItemsSource = src;
     //Population.ItemsSource = src;
     CreateDatabasePanel.Visibility = System.Windows.Visibility.Collapsed;
     HelpLabel.Visibility = System.Windows.Visibility.Collapsed;
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:16,代码来源:WorldCities.xaml.cs

示例2: Recover1

 public void Recover1(SessionBase session)
 {
   Database db = null;
   session.BeginUpdate();
   db = session.OpenDatabase(88, true, false);
   if (db != null)
     session.DeleteDatabase(db);
   db = session.OpenDatabase(89, true, false);
   if (db != null)
     session.DeleteDatabase(db);
   session.Commit();
   session.BeginUpdate();
   db = session.NewDatabase(88);
   session.FlushUpdates();
   session.Abort();
   session.BeginUpdate();
   db = session.NewDatabase(88);
   SortedSetAny<float> floatSet;
   Oid floatSetOid;
   string dbPath = System.IO.Path.Combine(systemDir, "89.odb");
   Placement place = new Placement(88);
   for (int i = 0; i < 10; i++)
   {
     floatSet = new SortedSetAny<float>();
     floatSet.Persist(place, session);
     floatSetOid = floatSet.Oid;
   }
   db = session.NewDatabase(89);
   session.Commit();
   File.Delete(dbPath);
   session.BeginUpdate();
   db = session.NewDatabase(89);
   session.Commit();
   FileInfo info = new FileInfo(dbPath);
   info.CopyTo(dbPath + "X");
   session.BeginUpdate();
   SortedSetAny<int> intSet;
   place = new Placement(89);
   for (int i = 0; i < 10; i++)
   {
     intSet = new SortedSetAny<int>();
     intSet.Persist(place, session);
   }
   db = session.OpenDatabase(88);
   var list = db.AllObjects<SortedSetAny<float>>();
   foreach (SortedSetAny<float> set in list)
     set.Unpersist(session);
   db = session.OpenDatabase(89);
   session.Commit();
   intSet = null;
   db = null; // release refs so that cached data isn't stale
   File.Delete(dbPath);
   info = new FileInfo(dbPath + "X");
   info.MoveTo(dbPath);
   session.BeginUpdate();
   intSet = (SortedSetAny<int>)session.Open(89, 1, 1, false);
   Debug.Assert(intSet == null);
   object o = session.Open(88, 1, 1, false);
   floatSet = (SortedSetAny<float>)o;
   Debug.Assert(floatSet != null);
   session.Commit();
   session.BeginUpdate();
   db = session.OpenDatabase(88);
   session.DeleteDatabase(db);
   db = session.OpenDatabase(89);
   session.DeleteDatabase(db);
   session.Commit();
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:68,代码来源:RecoveryTests.cs

示例3: SyncWith

 static public void SyncWith(this SessionBase sessionToUpdate, SessionBase sessionToRead, Func<SessionBase, UInt64, Change, bool> doUpdate)
 {
   UInt64 currentVersion;
   UInt64 pageToReadVersion;
   bool conflictFound = false;
   using (var reader = sessionToRead.BeginRead())
   {
     Changes changes = (Changes)sessionToRead.Open(5, 1, 1, false);
     if (changes != null)
     {
       using (var updater = sessionToUpdate.BeginUpdate())
       {
         var dbs = sessionToUpdate.OpenAllDatabases();
         ReplicaSync matchingReplicaSync = null;
         foreach (ReplicaSync sync in sessionToUpdate.AllObjects<ReplicaSync>())
         {
           if (sync.SyncFromHost == sessionToRead.SystemHostName && sync.SyncFromPath == sessionToRead.SystemDirectory)
           {
             matchingReplicaSync = sync;
             break;
           }
         }
         if (changes.ChangeList.Count > 0)
         {
           foreach (TransactionChanges transactionChanges in changes.ChangeList)
           {
             if (matchingReplicaSync == null || matchingReplicaSync.TransactionNumber < transactionChanges.TransactionNumber)
             {
               foreach (Change change in transactionChanges.ChangeList)
               {
                 Database dbToUpdate = sessionToUpdate.OpenDatabase(change.DatabaseId, false, false);
                 Database dbToRead = sessionToRead.OpenDatabase(change.DatabaseId, false, false);
                 string dbName = dbToRead != null ? dbToRead.Name : null;
                 if (change.Deleted)
                 {
                   if (dbToUpdate == null) // does not exist
                     continue;
                   if (change.PageId == 0) // Database delete
                   {
                     currentVersion = dbToUpdate.Page.PageInfo.VersionNumber;
                     if (currentVersion < change.Version)
                       sessionToUpdate.DeleteDatabase(dbToUpdate);
                     else
                     {
                       conflictFound = true;
                       if (doUpdate(sessionToUpdate, currentVersion, change))
                         sessionToUpdate.DeleteDatabase(dbToUpdate);
                     }
                   }
                   else
                   {
                     Page page = sessionToUpdate.OpenPage(dbToUpdate, change.PageId);
                     if (page == null) // page does not exist
                       continue;
                     currentVersion = page.PageInfo.VersionNumber;
                     if (currentVersion < change.Version)
                       sessionToUpdate.DeletePage(dbToUpdate, page);
                     else
                     {
                       conflictFound = true;
                       if (doUpdate(sessionToUpdate, currentVersion, change))
                         sessionToUpdate.DeleteDatabase(dbToUpdate);
                     }
                   }
                 }
                 else
                 {
                   if (dbToUpdate == null) // does not exist
                     dbToUpdate = sessionToUpdate.NewDatabase(change.DatabaseId, 0, dbName);
                   if (change.PageId > 0)
                   {
                     Page pageToUpdate = sessionToUpdate.OpenPage(dbToUpdate, change.PageId);
                     Page pageToRead = sessionToRead.OpenPage(dbToRead, change.PageId);
                     if (pageToRead == null) // upcoming (not yet processed) changes must have deleted this page
                       continue;
                     currentVersion = pageToUpdate == null ? 0 : pageToUpdate.PageInfo.VersionNumber;
                     pageToReadVersion = pageToRead.PageInfo.VersionNumber;
                     if (currentVersion < pageToReadVersion || dbToUpdate.IsNew)
                       sessionToUpdate.ReplacePage(dbToUpdate, pageToUpdate, pageToRead);
                     else
                     {
                       conflictFound = true;
                       if (doUpdate(sessionToUpdate, currentVersion, change))
                         sessionToUpdate.ReplacePage(dbToUpdate, pageToUpdate, pageToRead);
                     }
                   }
                 }
               }
             }
           }
           UInt64 lastTransactionNumber = changes.ChangeList.Last().TransactionNumber;
           if (matchingReplicaSync != null)
             matchingReplicaSync.TransactionNumber = lastTransactionNumber;
           if (conflictFound)
           {
             sessionToUpdate.Verify();
           }
           sessionToUpdate.Commit();
           if (matchingReplicaSync == null)
           {
//.........这里部分代码省略.........
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:101,代码来源:Sync.cs


注:本文中的SessionBase.OpenDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。