本文整理汇总了C#中SessionBase.ForceDatabaseCacheValidation方法的典型用法代码示例。如果您正苦于以下问题:C# SessionBase.ForceDatabaseCacheValidation方法的具体用法?C# SessionBase.ForceDatabaseCacheValidation怎么用?C# SessionBase.ForceDatabaseCacheValidation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionBase
的用法示例。
在下文中一共展示了SessionBase.ForceDatabaseCacheValidation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LockConflict
void LockConflict(SessionBase sharedReadSession)
{
string host = null;
Random r = new Random(5);
SessionPool sessionPool = new SessionPool(3, () => new ServerClientSession(systemDir, host, 2000, false));
try
{
int iCounter = 0;
int sessionId1 = -1;
SessionBase session1 = null;
for (int i = 0; i < 50; i++)
{
try
{
session1 = sessionPool.GetSession(out sessionId1);
session1.BeginUpdate();
Dokument Doc_A = new Dokument();
Doc_A.Name = "Test A";
session1.Persist(Doc_A);
Console.WriteLine(Doc_A.ToString());
int sessionId2 = -1;
SessionBase session2 = null;
try
{
session2 = sessionPool.GetSession(out sessionId2);
session2.BeginUpdate();
Dokument Doc_B = new Dokument();
Doc_B.Name = "Test_B";
session2.Persist(Doc_B);
Console.WriteLine(Doc_B.ToString());
session2.Commit();
}
finally
{
sessionPool.FreeSession(sessionId2, session2);
}
session1.Commit();
sharedReadSession.ForceDatabaseCacheValidation();
session1.BeginRead();
ulong ct = session1.AllObjects<Dokument>(false).Count;
Console.WriteLine("Number of Dokument found by normal session: " + ct);
session1.Commit();
ct = sharedReadSession.AllObjects<Dokument>(false).Count;
Console.WriteLine("Number of Dokument found by shared read session: " + ct);
}
finally
{
sessionPool.FreeSession(sessionId1, session1);
}
iCounter++;
Console.WriteLine(" -> " + iCounter.ToString());
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw;
}
}