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


C# SessionNoServer.SyncWith方法代码示例

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


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

示例1: aSyncNewDatabases

    public void aSyncNewDatabases()
    {
      using (SessionBase session = new SessionNoServer(s_sync1))
      {
        session.EnableSyncByTrackingChanges = true;
        using (var trans = session.BeginUpdate())
        {
          for (uint i = 10; i < 50; i++)
          {
            var database = session.NewDatabase(i);
            Assert.NotNull(database);
          }
          session.Commit();
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
            updateSession.SyncWith(readFromSession);
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        readFromSession.BeginRead();
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          using (var trans = updateSession.BeginRead())
          {
            Assert.AreEqual(updateSession.OpenAllDatabases().Count, readFromSession.OpenAllDatabases().Count - 1); // - 1 due to additional change tracking databases in original 
          }
        }
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:36,代码来源:SyncTest.cs

示例2: SyncFederationMenuItem_Click

 private void SyncFederationMenuItem_Click(object sender, RoutedEventArgs e)
 {
   MenuItem menuItem = (MenuItem)sender;
   FederationViewModel view = (FederationViewModel)menuItem.DataContext;
   FederationInfo info = view.Federationinfo;
   SessionBase session = view.Session;
   var lDialog = new System.Windows.Forms.FolderBrowserDialog()
   {
     Description = "Choose Federation Sync Destination Folder",
   };
   if (lDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
   {
     string destdir = lDialog.SelectedPath;
     if (session.InTransaction)
       session.Commit(); // must not be in transaction while copying databases
     using (SessionBase sessionDestination = new SessionNoServer(destdir))
     {
       sessionDestination.SyncWith(session);
     }
     m_viewModel = new AllFederationsViewModel();
     base.DataContext = m_viewModel;
     MessageBox.Show("Databases synced with " + destdir + " at " + DateTime.Now);
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:24,代码来源:MainWindow.xaml.cs

示例3: bSyncDeletedDatabases

    public void bSyncDeletedDatabases()
    {
      using (SessionBase session = new SessionNoServer(s_sync1))
      {
        using (var trans = session.BeginUpdate())
        {
          for (uint i = 10; i < 14; i++)
          {
            var database = session.OpenDatabase(i);
            session.DeleteDatabase(database);
          }
          session.Commit();
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          updateSession.SyncWith(readFromSession);
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        readFromSession.BeginRead();
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          using (var trans = updateSession.BeginRead())
          {
            Assert.AreEqual(updateSession.OpenAllDatabases().Count, readFromSession.OpenAllDatabases().Count - 1); // - 1 due to additional change tracking databases in original 
          }
        }
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:35,代码来源:SyncTest.cs

示例4: dSyncDeletePages

    public void dSyncDeletePages()
    {
      using (SessionBase session = new SessionNoServer(s_sync1))
      {
        using (var trans = session.BeginUpdate())
        {
          foreach (FourPerPage fourPerPage in session.AllObjects<FourPerPage>())
            fourPerPage.Unpersist(session);
          session.Commit();
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          updateSession.SyncWith(readFromSession);
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        readFromSession.BeginRead();
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          using (var trans = updateSession.BeginRead())
          {
            Assert.AreEqual(updateSession.AllObjects<FourPerPage>().Count, readFromSession.AllObjects<FourPerPage>().Count);
          }
        }
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:32,代码来源:SyncTest.cs

示例5: cSyncNewPages

    public void cSyncNewPages()
    {
      using (SessionBase session = new SessionNoServer(s_sync1))
      {
        using (var trans = session.BeginUpdate())
        {
          for (uint i = 0; i < 100; i++)
          {
            FourPerPage fourPerPage = new FourPerPage(i);
            session.Persist(fourPerPage);
          }
          session.Commit();
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          updateSession.SyncWith(readFromSession);
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        readFromSession.BeginRead();
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          using (var trans = updateSession.BeginRead())
          {
            Assert.AreEqual(updateSession.AllObjects<FourPerPage>().Count, readFromSession.AllObjects<FourPerPage>().Count);
          }
        }
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:35,代码来源:SyncTest.cs


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