本文整理汇总了C#中ODatabase.Gremlin方法的典型用法代码示例。如果您正苦于以下问题:C# ODatabase.Gremlin方法的具体用法?C# ODatabase.Gremlin怎么用?C# ODatabase.Gremlin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ODatabase
的用法示例。
在下文中一共展示了ODatabase.Gremlin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldExecuteSimpleGremlinQuery
public void ShouldExecuteSimpleGremlinQuery()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
OVertex vertex1 = database
.Create.Vertex<OVertex>()
.Set("Foo", "foo string value 1")
.Set("Bar", 12345)
.Run();
OVertex vertex2 = database
.Create.Vertex<OVertex>()
.Set("Foo", "foo string value 2")
.Set("Bar", 54321)
.Run();
OEdge edge1 = database
.Create.Edge<OEdge>()
.From(vertex1)
.To(vertex2)
.Set("Foo", "foo string value 3")
.Set("Bar", 123)
.Run();
List<ODocument> documents = database.Gremlin("g.V");
}
}
}
示例2: ShouldExecuteSimpleGremlinQuery
public void ShouldExecuteSimpleGremlinQuery()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
OVertex vertex1 = database
.Create.Vertex<OVertex>()
.Set("Foo", "foo string value 1")
.Set("Bar", 12345)
.Run();
OVertex vertex2 = database
.Create.Vertex<OVertex>()
.Set("Foo", "foo string value 2")
.Set("Bar", 54321)
.Run();
OEdge edge1 = database
.Create.Edge<OEdge>()
.From(vertex1)
.To(vertex2)
.Set("Foo", "foo string value 3")
.Set("Bar", 123)
.Run();
List<ODocument> documents = database.Gremlin("g.V").ToList();
Assert.AreEqual(2, documents.Count);
var loadedVertex1 = documents.Find(d => d.ORID.Equals(vertex1.ORID));
var loadedVertex2 = documents.Find(d => d.ORID.Equals(vertex2.ORID));
Assert.IsNotNull(loadedVertex1);
Assert.IsNotNull(loadedVertex2);
Assert.AreEqual(vertex1.GetField<string>("Foo"), loadedVertex1.GetField<string>("Foo"));
Assert.AreEqual(vertex1.GetField<int>("Bar"), loadedVertex1.GetField<int>("Bar"));
Assert.AreEqual(vertex2.GetField<string>("Foo"), loadedVertex2.GetField<string>("Foo"));
Assert.AreEqual(vertex2.GetField<int>("Bar"), loadedVertex2.GetField<int>("Bar"));
Assert.AreEqual(1, loadedVertex1.GetField<HashSet<ORID>>("out_").Count);
Assert.IsTrue(loadedVertex1.GetField<HashSet<ORID>>("out_").Contains(edge1.ORID));
Assert.IsTrue(loadedVertex2.GetField<HashSet<ORID>>("in_").Contains(edge1.ORID));
}
}
}