本文整理汇总了C#中ODatabase类的典型用法代码示例。如果您正苦于以下问题:C# ODatabase类的具体用法?C# ODatabase怎么用?C# ODatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODatabase类属于命名空间,在下文中一共展示了ODatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: LoadRecord
public LoadRecord(ORID orid, string fetchPlan, ODatabase database)
: this(database)
{
_orid = orid;
_fetchPlan = fetchPlan;
_database = database;
}
示例3: ShouldDeleteDocumentFromObjectOClassName
public void ShouldDeleteDocumentFromObjectOClassName()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// prerequisites
database
.Create.Class<TestProfileClass>()
.Run();
TestProfileClass profile = new TestProfileClass();
profile.Name = "Johny";
profile.Surname = "Bravo";
database
.Create.Document(profile)
.Run();
database
.Create.Document(profile)
.Run();
int documentsDeleted = database
.Delete.Document(profile)
.Run();
Assert.AreEqual(documentsDeleted, 2);
}
}
}
示例4: Init
public void Init()
{
_context = new TestDatabaseContext();
_database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
_database.Create.Class<Person>().Run();
}
示例5: ShouldInsertDocumentInto
public void ShouldInsertDocumentInto()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// prerequisites
database
.Create.Class("TestClass")
.Run();
ODocument document = new ODocument()
.SetField("foo", "foo string value")
.SetField("bar", 12345);
ODocument insertedDocument = database
.Insert(document)
.Into("TestClass")
.Run();
Assert.IsTrue(insertedDocument.ORID != null);
Assert.AreEqual(insertedDocument.OClassName, "TestClass");
Assert.AreEqual(insertedDocument.GetField<string>("foo"), document.GetField<string>("foo"));
Assert.AreEqual(insertedDocument.GetField<int>("bar"), document.GetField<int>("bar"));
}
}
}
示例6: RecordCreate
public RecordCreate(ODocument document, ODatabase database)
: base(database)
{
_document = document;
_database = database;
_operationType = OperationType.RECORD_CREATE;
}
示例7: TestDatabaseClusterAddRemove
public void TestDatabaseClusterAddRemove()
{
using (ODatabase database = new ODatabase(_hostname, _port, _databaseName, ODatabaseType.Document, _username, _password))
{
OCluster newCluster = database.AddCluster(OClusterType.Physical, "tempClusterTest001x");
Assert.IsTrue(newCluster.ID >= 0);
Assert.IsTrue(!string.IsNullOrEmpty(newCluster.Name));
Assert.IsTrue(newCluster.RecordsCount == 0);
database.Reload();
OCluster cluster = database.Clusters.Find(x => x.ID == newCluster.ID);
Assert.IsTrue(cluster.ID >= newCluster.ID);
Assert.IsTrue(cluster.Name.Equals(newCluster.Name, StringComparison.CurrentCultureIgnoreCase));
Assert.IsTrue(cluster.RecordsCount == newCluster.RecordsCount);
database.RemoveCluster(newCluster.ID);
OCluster cluster2 = database.Clusters.Find(x => x.ID == newCluster.ID);
Assert.IsNull(cluster2);
database.Reload();
OCluster cluster3 = database.Clusters.Find(x => x.ID == newCluster.ID);
Assert.IsNull(cluster3);
}
}
示例8: ShouldCreateVertexFromDocument
public void ShouldCreateVertexFromDocument()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// prerequisites
database
.Create.Class("TestVertexClass")
.Extends<OVertex>()
.Run();
ODocument document = new ODocument();
document.OClassName = "TestVertexClass";
document
.SetField("foo", "foo string value")
.SetField("bar", 12345);
OVertex createdVertex = database
.Create.Vertex(document)
.Run();
Assert.IsNotNull(createdVertex.ORID);
Assert.AreEqual("TestVertexClass", createdVertex.OClassName);
Assert.AreEqual(document.GetField<string>("foo"), createdVertex.GetField<string>("foo"));
Assert.AreEqual(document.GetField<int>("bar"), createdVertex.GetField<int>("bar"));
}
}
}
示例9: ShouldCreateVertexSet
public void ShouldCreateVertexSet()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// prerequisites
database
.Create.Class("TestVertexClass")
.Extends<OVertex>()
.Run();
OVertex createdVertex = database
.Create.Vertex("TestVertexClass")
.Set("foo", "foo string value")
.Set("bar", 12345)
.Run();
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);
}
}
}
示例10: ShouldCreateClassCluster
public void ShouldCreateClassCluster()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
short clusterid1 = database
.Create
.Cluster("ClasterForTest1", OClusterType.None)
.Run();
short clusterid2 = database
.Create
.Cluster("ClasterForTest2", OClusterType.None)
.Run();
short classId1 = database
.Create.Class("TestClass1")
.Cluster(clusterid1)
.Run();
Assert.IsTrue(classId1 > 0);
short classId2 = database
.Create.Class("TestClass2")
.Cluster(clusterid2)
.Run();
Assert.AreEqual(classId1 + 1, classId2);
}
}
}
示例11: ShouldCreateDocumentClassSet
public void ShouldCreateDocumentClassSet()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// prerequisites
database
.Create.Class("TestClass")
.Run();
ODocument document = new ODocument();
document.OClassName = "TestClass";
document
.SetField("foo", "foo string value")
.SetField("bar", 12345);
ODocument createdDocument = database
.Create.Document("TestClass")
.Set(document)
.Run();
Assert.NotNull(createdDocument.ORID);
Assert.Equal("TestClass", createdDocument.OClassName);
Assert.Equal(document.GetField<string>("foo"), createdDocument.GetField<string>("foo"));
Assert.Equal(document.GetField<int>("bar"), createdDocument.GetField<int>("bar"));
}
}
}
示例12: ShouldCreateDocumentFromObject
public void ShouldCreateDocumentFromObject()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// prerequisites
database
.Create.Class<TestProfileClass>()
.Run();
TestProfileClass profile = new TestProfileClass();
profile.Name = "Johny";
profile.Surname = "Bravo";
TestProfileClass createdObject = database
.Create.Document(profile)
.Run<TestProfileClass>();
Assert.NotNull(createdObject.ORID);
Assert.Equal(typeof(TestProfileClass).Name, createdObject.OClassName);
Assert.Equal(profile.Name, createdObject.Name);
Assert.Equal(profile.Surname, createdObject.Surname);
}
}
}
示例13: GitHub_issue23
public GitHub_issue23()
{
_context = new TestDatabaseContext();
_database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
_database.Create.Class<DemoEmployee>().Run();
}
示例14: ShouldFetchLinkedDocumentsFromSimpleQuery
public void ShouldFetchLinkedDocumentsFromSimpleQuery()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
database.Create.Class("Owner").Extends("V").Run();
database.Create.Class("Computer").Extends("V").Run();
var owner = new ODocument { OClassName = "Owner" };
owner.SetField<String>("name", "Shawn");
owner = database.Create.Vertex(owner).Run();
var computer = new ODocument { OClassName = "Computer" };
computer.SetField<ORID>("owner", owner.ORID);
database.Create.Vertex(computer).Run();
computer = database.Query("SELECT FROM Computer", "*:-1").FirstOrDefault();
Assert.That(database.ClientCache.ContainsKey(computer.GetField<ORID>("owner")));
var document = database.ClientCache[computer.GetField<ORID>("owner")];
Assert.That(document.GetField<string>("name"), Is.EqualTo("Shawn"));
}
}
示例15: Test
static void Test()
{
_connection = new OServer(_hostname, _port, _rootName, _rootPassword);
if (!_connection.DatabaseExist(_databaseName))
{
_connection.CreateDatabase(_databaseName, ODatabaseType.Document, OStorageType.Local);
}
try
{
using (ODatabase database = new ODatabase(_hostname, _port, _databaseName, ODatabaseType.Document, _username, _password))
{
Console.WriteLine("Session ID: {0}", database.SessionID);
}
}
catch (OException ex)
{
//Console.WriteLine("{0}: {1}", ex.Type, ex.Description);
}
finally
{
// delete test database
_connection.DeleteDatabase(_databaseName);
_connection.Close();
}
}