当前位置: 首页>>代码示例>>C#>>正文


C# ODatabase类代码示例

本文整理汇总了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");
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:30,代码来源:GremlinTests.cs

示例2: LoadRecord

 public LoadRecord(ORID orid, string fetchPlan, ODatabase database)
     : this(database)
 {
     _orid = orid;
     _fetchPlan = fetchPlan;
     _database = database;
 }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:7,代码来源:LoadRecord.cs

示例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);
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:31,代码来源:SqlDeleteDocumentTests.cs

示例4: Init

        public void Init()
        {
            _context = new TestDatabaseContext();
            _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);

            _database.Create.Class<Person>().Run();
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:7,代码来源:GitHub_issue62.cs

示例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"));


                }
            }
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:29,代码来源:SqlInsertTests.cs

示例6: RecordCreate

 public RecordCreate(ODocument document, ODatabase database)
     : base(database)
 {
     _document = document;
     _database = database;
     _operationType = OperationType.RECORD_CREATE;
 }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:7,代码来源:RecordCreate.cs

示例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);
            }
        }
开发者ID:yojimbo87,项目名称:Eastern,代码行数:31,代码来源:ODatabaseTests.cs

示例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"));
                }
            }
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:29,代码来源:SqlCreateVertexTests.cs

示例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);
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:25,代码来源:SqlCreateVertexTests.cs

示例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);
                }
            }
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:32,代码来源:SqlCreateClassTests.cs

示例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"));
                }
            }
        }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:29,代码来源:SqlCreateDocumentTests.cs

示例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);
                }
            }
        }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:26,代码来源:SqlCreateDocumentTests.cs

示例13: GitHub_issue23

        public GitHub_issue23()
        {
            _context = new TestDatabaseContext();
            _database = new ODatabase(TestConnection.GlobalTestDatabaseAlias);
            _database.Create.Class<DemoEmployee>().Run();

        }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:7,代码来源:GitHub_issue23.cs

示例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"));
            }
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:26,代码来源:SqlQueryTests.cs

示例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();
            }
        }
开发者ID:yojimbo87,项目名称:Eastern,代码行数:28,代码来源:Program.cs


注:本文中的ODatabase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。