本文整理汇总了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
}
}
}
}
示例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);
}
}
示例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
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}