本文整理汇总了C#中ODatabase.GetClusterIdFor方法的典型用法代码示例。如果您正苦于以下问题:C# ODatabase.GetClusterIdFor方法的具体用法?C# ODatabase.GetClusterIdFor怎么用?C# ODatabase.GetClusterIdFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ODatabase
的用法示例。
在下文中一共展示了ODatabase.GetClusterIdFor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCreateVertex
public void TestCreateVertex()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// prerequisites
database
.Create.Class("TestVertexClass")
.Extends<OVertex>()
.Run();
OVertex testVertex = new OVertex();
testVertex.OClassName = "TestVertexClass";
testVertex.SetField("foo", "foo string value");
testVertex.SetField("bar", 12345);
Assert.AreEqual(null, testVertex.ORID);
database.Transaction.Add(testVertex);
Assert.IsNotNull(testVertex.ORID);
Assert.IsTrue(testVertex.ORID.ClusterPosition < 0);
Assert.AreEqual(-2, testVertex.ORID.ClusterPosition);
database.Transaction.Commit();
Assert.IsNotNull(testVertex.ORID);
Assert.AreEqual(database.GetClusterIdFor("TestVertexClass"), testVertex.ORID.ClusterId);
var createdVertex = database.Load.ORID(testVertex.ORID).Run().To<OVertex>();
Assert.IsTrue(createdVertex.ORID != null);
Assert.AreEqual("TestVertexClass", createdVertex.OClassName);
Assert.AreEqual("foo string value", createdVertex.GetField<string>("foo"));
Assert.AreEqual(12345, createdVertex.GetField<int>("bar"));
}
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
OVertex testVertex = new OVertex();
testVertex.OClassName = "TestVertexClass";
testVertex.SetField("foo", "foo string value");
testVertex.SetField("bar", 12345);
Assert.AreEqual(null, testVertex.ORID);
database.Transaction.Add(testVertex);
Assert.IsNotNull(testVertex.ORID);
Assert.IsTrue(testVertex.ORID.ClusterPosition < 0);
Assert.AreEqual(-2, testVertex.ORID.ClusterPosition);
database.Transaction.Commit();
Assert.IsNotNull(testVertex.ORID);
Assert.AreEqual(database.GetClusterIdFor("TestVertexClass"), testVertex.ORID.ClusterId);
Assert.AreNotEqual(-2, testVertex.ORID.ClusterPosition);
var createdVertex = database.Load.ORID(testVertex.ORID).Run().To<OVertex>();
Assert.IsTrue(createdVertex.ORID != null);
Assert.AreEqual(createdVertex.OClassName, "TestVertexClass");
Assert.AreEqual(createdVertex.GetField<string>("foo"), "foo string value");
Assert.AreEqual(createdVertex.GetField<int>("bar"), 12345);
}
}
}