/// <summary> /// Creates a graph using the current session /// </summary> public void CreateClassicGraph(IDseSession session, string name) { session.ExecuteGraph(new SimpleGraphStatement(string.Format("system.graph('{0}').ifNotExists().create()", name))); session.ExecuteGraph(new SimpleGraphStatement(MakeStrict).SetGraphName(name)); session.ExecuteGraph(new SimpleGraphStatement(AllowScans).SetGraphName(name)); session.ExecuteGraph(new SimpleGraphStatement(ClassicSchemaGremlinQuery).SetGraphName(name)); session.ExecuteGraph(new SimpleGraphStatement(ClassicLoadGremlinQuery).SetGraphName(name)); }
public async Task With_GraphSON2_It_Should_Insert_And_Retrieve_LocalDate_LocalTime() { const string schemaQuery = "schema.propertyKey('localdate').Date().ifNotExists().create();\n" + "schema.propertyKey('localtime').Time().ifNotExists().create();\n" + "schema.vertexLabel('typetests').properties('name', 'localdate', 'localtime').ifNotExists().create();\n"; _session.ExecuteGraph(new SimpleGraphStatement(schemaQuery)); var deleteStatement = new SimpleGraphStatement("{\"@type\": \"g:Bytecode\", \"step\": " + "[[\"V\"], [\"has\", \"typetests\", \"name\", \"stephen\"],[\"drop\"]}}"); deleteStatement.SetGraphLanguage(GraphSON2Language); _session.ExecuteGraph(deleteStatement); var addStatement = new SimpleGraphStatement("{\"@type\":\"Bytecode\",\"step\":[" + "[\"addV\", \"typetests\"],[\"property\",\"name\",\"stephen\"]," + "[\"property\",{\"@type\":\"T\",\"value\":\"gx:LocalDate\"},\"localdate\", \"1981-09-14\"]," + "[\"property\",{\"@type\":\"T\",\"value\":\"gx:LocalTime\"},\"localtime\", \"12:50\"]]}"); addStatement.SetGraphLanguage(GraphSON2Language); await _session.ExecuteGraphAsync(addStatement).ConfigureAwait(false); var statement = new SimpleGraphStatement("{\"@type\": \"g:Bytecode\", \"@value\": {" + " \"step\": [[\"V\"], [\"has\", \"typetests\", \"name\", \"stephen\"]]}}"); statement.SetGraphLanguage(GraphSON2Language); var rs = await _session.ExecuteGraphAsync(statement).ConfigureAwait(false); var results = rs.ToArray(); Assert.AreEqual(1, results.Length); var stephen = rs.FirstOrDefault().ToVertex(); Assert.AreEqual("stephen", stephen.Properties["name"].ToArray()[0].Get <string>("value")); Assert.AreEqual(LocalDate.Parse("1981-09-14"), stephen.Properties["localdate"].ToArray()[0].Get <LocalDate>("value")); Assert.AreEqual(LocalTime.Parse("12:50"), stephen.Properties["localtime"].ToArray()[0].Get <LocalTime>("value")); }