本文整理汇总了C#中IExtObjectContainer.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# IExtObjectContainer.Commit方法的具体用法?C# IExtObjectContainer.Commit怎么用?C# IExtObjectContainer.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExtObjectContainer
的用法示例。
在下文中一共展示了IExtObjectContainer.Commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
_FilePath = Path.GetTempFileName();
_db = Db4oFactory.OpenFile(_FilePath).Ext();
TestClass testClass = new TestClass();
testClass.Label = "Meal times";
testClass.Times = new List<Time>();
testClass.Times.Add(new Time(7, 30));
testClass.Times.Add(new Time(12, 0));
testClass.Times.Add(new Time(17, 20));
_db.Set(testClass, 5);
testClass = new TestClass();
testClass.Label = "Free time";
testClass.Times = new List<Time>();
_db.Set(testClass, 5);
testClass = new TestClass();
testClass.Label = "Bed time";
testClass.Times = new List<Time>();
testClass.Times.Add(new Time(21, 30));
_db.Set(testClass, 5);
_db.Commit();
}
示例2: Conc
public virtual void Conc(IExtObjectContainer oc)
{
IsStoredTestCase isStored = new IsStoredTestCase();
isStored.myString = "isStored";
oc.Store(isStored);
Assert.IsTrue(oc.IsStored(isStored));
oc.Commit();
oc.Delete(isStored);
Assert.IsFalse(oc.IsStored(isStored));
oc.Rollback();
Assert.IsTrue(oc.IsStored(isStored));
oc.Delete(isStored);
Assert.IsFalse(oc.IsStored(isStored));
oc.Commit();
Assert.IsFalse(oc.IsStored(isStored));
}
示例3: Conc
/// <exception cref="System.Exception"></exception>
public virtual void Conc(IExtObjectContainer oc)
{
IObjectSet os = oc.Query(typeof(InvalidUUIDTestCase));
if (os.Count == 0)
{
// already deleted by other threads
return;
}
Assert.AreEqual(1, os.Count);
InvalidUUIDTestCase iu = (InvalidUUIDTestCase)os.Next();
Db4oUUID myUuid = oc.GetObjectInfo(iu).GetUUID();
Assert.IsNotNull(myUuid);
byte[] mySignature = myUuid.GetSignaturePart();
long myLong = myUuid.GetLongPart();
long unknownLong = long.MaxValue - 100;
byte[] unknownSignature = new byte[] { 1, 2, 4, 99, 33, 22 };
Db4oUUID unknownLongPart = new Db4oUUID(unknownLong, mySignature);
Db4oUUID unknownSignaturePart = new Db4oUUID(myLong, unknownSignature);
Db4oUUID unknownBoth = new Db4oUUID(unknownLong, unknownSignature);
Assert.IsNull(oc.GetByUUID(unknownLongPart));
Assert.IsNull(oc.GetByUUID(unknownSignaturePart));
Assert.IsNull(oc.GetByUUID(unknownBoth));
Assert.IsNull(oc.GetByUUID(unknownLongPart));
Thread.Sleep(500);
oc.Delete(iu);
oc.Commit();
Assert.IsNull(oc.GetByUUID(myUuid));
}
示例4: CommitCapturingUpdatedObjects
private Collection4 CommitCapturingUpdatedObjects(IExtObjectContainer container)
{
var updated = new Collection4();
EventRegistryFor(container).Updated += new _IEventListener4_51(updated).OnEvent;
container.Commit();
return updated;
}
示例5: CommitCapturingUpdatedObjects
private Collection4 CommitCapturingUpdatedObjects(IExtObjectContainer container)
{
Collection4 updated = new Collection4();
EventRegistryFor(container).Updated += new System.EventHandler<Db4objects.Db4o.Events.ObjectInfoEventArgs>
(new _IEventListener4_51(updated).OnEvent);
container.Commit();
return updated;
}
示例6: Conc
public virtual void Conc(IExtObjectContainer oc)
{
ExtMethodsTestCase em = new ExtMethodsTestCase();
oc.Store(em);
Assert.IsFalse(oc.IsClosed());
Assert.IsTrue(oc.IsActive(em));
Assert.IsTrue(oc.IsStored(em));
oc.Deactivate(em, 1);
Assert.IsTrue(!oc.IsActive(em));
oc.Activate(em, 1);
Assert.IsTrue(oc.IsActive(em));
long id = oc.GetID(em);
Assert.IsTrue(oc.IsCached(id));
oc.Purge(em);
Assert.IsFalse(oc.IsCached(id));
Assert.IsFalse(oc.IsStored(em));
Assert.IsFalse(oc.IsActive(em));
oc.Bind(em, id);
Assert.IsTrue(oc.IsCached(id));
Assert.IsTrue(oc.IsStored(em));
Assert.IsTrue(oc.IsActive(em));
ExtMethodsTestCase em2 = (ExtMethodsTestCase)oc.GetByID(id);
Assert.AreSame(em, em2);
// Purge all and try again
oc.Purge();
Assert.IsTrue(oc.IsCached(id));
Assert.IsTrue(oc.IsStored(em));
Assert.IsTrue(oc.IsActive(em));
em2 = (ExtMethodsTestCase)oc.GetByID(id);
Assert.AreSame(em, em2);
oc.Delete(em2);
oc.Commit();
Assert.IsFalse(oc.IsCached(id));
Assert.IsFalse(oc.IsStored(em2));
Assert.IsFalse(oc.IsActive(em2));
// Null checks
Assert.IsFalse(oc.IsStored(null));
Assert.IsFalse(oc.IsActive(null));
Assert.IsFalse(oc.IsCached(0));
}
示例7: ConcDelete
/// <exception cref="System.Exception"></exception>
public virtual void ConcDelete(IExtObjectContainer oc)
{
var os = oc.Query(typeof (Item));
if (os.Count == 0)
{
// the object has been deleted
return;
}
if (!os.HasNext())
{
// object can be deleted after query
return;
}
var cdf = (Item) os.Next();
// sleep 1000 ms, waiting for other threads.
// Thread.sleep(500);
oc.Delete(cdf);
oc.Commit();
AssertOccurrences(oc, typeof (Item), 0);
AssertOccurrences(oc, typeof (CascadeDeleteFalseHelper)
, 1);
}
示例8: Conc
/// <exception cref="System.Exception"></exception>
public virtual void Conc(IExtObjectContainer oc)
{
IQuery q = oc.Query();
q.Constrain(typeof(MultiDeleteTestCase));
q.Descend("name").Constrain("killmefirst");
IObjectSet objectSet = q.Execute();
if (objectSet.Count == 0)
{
// already deleted by other threads
return;
}
Assert.AreEqual(1, objectSet.Count);
Thread.Sleep(1000);
if (!objectSet.HasNext())
{
return;
}
MultiDeleteTestCase md = (MultiDeleteTestCase)objectSet.Next();
oc.Delete(md);
oc.Commit();
AssertOccurrences(oc, typeof(MultiDeleteTestCase), 0);
}
示例9: Conc
/// <exception cref="System.Exception"></exception>
public virtual void Conc(IExtObjectContainer oc)
{
IQuery q = oc.Query();
q.Constrain(typeof(DeleteDeepTestCase));
q.Descend("name").Constrain("root");
IObjectSet os = q.Execute();
if (os.Count == 0)
{
// already deleted
return;
}
Assert.AreEqual(1, os.Count);
if (!os.HasNext())
{
return;
}
DeleteDeepTestCase root = (DeleteDeepTestCase)os.Next();
// wait for other threads
// Thread.sleep(500);
oc.Delete(root);
oc.Commit();
AssertOccurrences(oc, typeof(DeleteDeepTestCase), 0);
}
示例10: Update
protected override void Update(IExtObjectContainer objectContainer)
{
objectContainer.Store(NewItem(2004, 2, 23));
objectContainer.Commit();
}
示例11: EnsureMessageProcessed
private static void EnsureMessageProcessed(IExtObjectContainer client)
{
client.Commit();
}
示例12: TTwoRef
private void TTwoRef(IExtObjectContainer oc, string name)
{
var commit = name.IndexOf("commit") > 1;
var delete = name.IndexOf("delete") > 1;
var q = oc.Query();
q.Constrain(typeof (Item));
q.Descend("name").Constrain(name);
var objectSet = q.Execute();
var item1 = (Item) objectSet
.Next();
var item2 = (Item) objectSet
.Next();
if (delete)
{
oc.Delete(item1.untypedMember);
oc.Delete(item1.typedMember);
}
oc.Delete(item1);
if (commit)
{
oc.Commit();
}
oc.Delete(item2);
if (!commit)
{
oc.Commit();
}
}
示例13: TMembersFirst
private void TMembersFirst(IExtObjectContainer oc, string name)
{
var commit = name.IndexOf("commit") > 1;
var q = oc.Query();
q.Constrain(typeof (Item));
q.Descend("name").Constrain(name);
var objectSet = q.Execute();
var cdd = (Item) objectSet
.Next();
oc.Delete(cdd.untypedMember);
oc.Delete(cdd.typedMember);
if (commit)
{
oc.Commit();
}
oc.Delete(cdd);
if (!commit)
{
oc.Commit();
}
}
示例14: TTwoRef
private void TTwoRef(IExtObjectContainer oc, string name)
{
bool commit = name.IndexOf("commit") > 1;
bool delete = name.IndexOf("delete") > 1;
IQuery q = oc.Query();
q.Constrain(typeof(CascadeDeleteDeletedTestCase.Item));
q.Descend("name").Constrain(name);
IObjectSet objectSet = q.Execute();
CascadeDeleteDeletedTestCase.Item item1 = (CascadeDeleteDeletedTestCase.Item)objectSet
.Next();
CascadeDeleteDeletedTestCase.Item item2 = (CascadeDeleteDeletedTestCase.Item)objectSet
.Next();
if (delete)
{
oc.Delete(item1.untypedMember);
oc.Delete(item1.typedMember);
}
oc.Delete(item1);
if (commit)
{
oc.Commit();
}
oc.Delete(item2);
if (!commit)
{
oc.Commit();
}
}
示例15: TMembersFirst
private void TMembersFirst(IExtObjectContainer oc, string name)
{
bool commit = name.IndexOf("commit") > 1;
IQuery q = oc.Query();
q.Constrain(typeof(CascadeDeleteDeletedTestCase.Item));
q.Descend("name").Constrain(name);
IObjectSet objectSet = q.Execute();
CascadeDeleteDeletedTestCase.Item cdd = (CascadeDeleteDeletedTestCase.Item)objectSet
.Next();
oc.Delete(cdd.untypedMember);
oc.Delete(cdd.typedMember);
if (commit)
{
oc.Commit();
}
oc.Delete(cdd);
if (!commit)
{
oc.Commit();
}
}