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


C# ODocument.GetField方法代码示例

本文整理汇总了C#中ODocument.GetField方法的典型用法代码示例。如果您正苦于以下问题:C# ODocument.GetField方法的具体用法?C# ODocument.GetField怎么用?C# ODocument.GetField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ODocument的用法示例。


在下文中一共展示了ODocument.GetField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestLoadWithFetchPlanNoLinks

        public void TestLoadWithFetchPlanNoLinks()
        {
            using (var testContext = new TestDatabaseContext())
            using (var 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();
                var loaded = database.Load.ORID(insertedDocument.ORID).FetchPlan("*:1").Run();
                Assert.AreEqual("TestClass", loaded.OClassName);
                Assert.AreEqual(document.GetField<string>("foo"), loaded.GetField<string>("foo"));
                Assert.AreEqual(document.GetField<int>("bar"), loaded.GetField<int>("bar"));
                Assert.AreEqual(insertedDocument.ORID, loaded.ORID);

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

示例2: 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

示例3: ShouldInsertDocument

        public void ShouldInsertDocument()
        {
            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 insertedDocument = database
                        .Insert(document)
                        .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,代码行数:28,代码来源:SqlInsertTests.cs

示例4: 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

示例5: ShouldUpdateClassFromDocument

        public void ShouldUpdateClassFromDocument()
        {
            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);

                    database
                        .Insert(document)
                        .Run();

                    database
                        .Insert(document)
                        .Run();

                    document
                        .SetField("bar", 54321)
                        .SetField("baz", "new baz value");

                    int documentsUpdated = database
                        .Update(document)
                        .Run();

                    Assert.AreEqual(documentsUpdated, 2);

                    List<ODocument> documents = database
                        .Select()
                        .From("TestClass")
                        .ToList();

                    Assert.AreEqual(documents.Count, 2);

                    for (int i = 0; i < documents.Count; i++)
                    {
                        Assert.IsTrue(documents[i].ORID != null);
                        Assert.AreEqual(documents[i].OClassName, document.OClassName);
                        Assert.AreEqual(documents[i].GetField<string>("foo"), document.GetField<string>("foo"));
                        Assert.AreEqual(documents[i].GetField<int>("bar"), document.GetField<int>("bar"));
                        Assert.AreEqual(documents[i].GetField<string>("baz"), document.GetField<string>("baz"));
                    }
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:53,代码来源:SqlUpdateTests.cs

示例6: CreateVertexWithHeavyEdgeTX

        public void CreateVertexWithHeavyEdgeTX()
        {
            var v1 = new ODocument { OClassName = "TestVertex" };
            v1.SetField("Name", "First");
            v1.SetField("Bar", 1);

            var v2 = new ODocument { OClassName = "TestVertex" };
            v2.SetField("Name", "Second");
            v2.SetField("Bar", 2);

            var e1 = new ODocument { OClassName = "TestEdge" };
            e1.SetField("Weight", 1.3f);

            // Add records to the transaction
            _database.Transaction.Add(v1);
            _database.Transaction.Add(v2);
            _database.Transaction.Add(e1);

            // link records
            v1.SetField("in_TestEdge", e1.ORID);
            v2.SetField("out_TestEdge", e1.ORID);
            e1.SetField("in", v1.ORID);
            e1.SetField("out", v2.ORID);

            _database.Transaction.Commit();

            Assert.NotNull(v1.ORID);
            Assert.NotNull(v2.ORID);
            Assert.NotNull(e1.ORID);

            var lv1 = _database.Load.ORID(v1.ORID).Run();
            var lv2 = _database.Load.ORID(v2.ORID).Run();
            var le1 = _database.Load.ORID(e1.ORID).Run();

            Assert.Equal(v1.GetField<string>("Name"), lv1.GetField<string>("Name"));
            Assert.Equal(v1.GetField<int>("Bar"), lv1.GetField<int>("Bar"));

            Assert.Equal(v2.GetField<string>("Name"), lv2.GetField<string>("Name"));
            Assert.Equal(v2.GetField<int>("Bar"), lv2.GetField<int>("Bar"));

            Assert.Equal(e1.GetField<float>("Weight"), le1.GetField<float>("Weight"));

            Assert.Equal(e1.ORID, lv1.GetField<ORID>("in_TestEdge"));
            Assert.Equal(e1.ORID, lv2.GetField<ORID>("out_TestEdge"));

            Assert.Equal(v1.ORID, le1.GetField<ORID>("in"));
            Assert.Equal(v2.ORID, le1.GetField<ORID>("out"));

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

示例7: ShouldSelectUntyped

        public void ShouldSelectUntyped()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    string className = "TestVertexClass";

                    ODocument document1 = new ODocument();
                    document1
                        .SetField("foo", "foo string value1")
                        .SetField("bar", 12345);

                    ODocument document2 = new ODocument();
                    document2
                        .SetField("foo", "foo string value2")
                        .SetField("bar", 54321);

                    // create test class
                    database
                        .Create.Class("TestVertexClass")
                        .Extends("OGraphVertex")
                        .Run();

                    // load database with some testing data
                    database
                        .Create.Vertex(className)
                        .Set(document1)
                        .Run();

                    database
                        .Create.Vertex(className)
                        .Set(document2)
                        .Run();

                    // perform simple select
                    List<ORecord> result = database
                        .Select("foo", "bar")
                        .From("TestVertexClass")
                        .ToList();

                    Assert.AreEqual(result.Count, 2);
                    Assert.AreEqual(result[0].GetField<string>("foo"), document1.GetField<string>("foo"));
                    Assert.AreEqual(result[0].GetField<int>("bar"), document1.GetField<int>("bar"));
                    Assert.AreEqual(result[1].GetField<string>("foo"), document2.GetField<string>("foo"));
                    Assert.AreEqual(result[1].GetField<int>("bar"), document2.GetField<int>("bar"));
                }
            }
        }
开发者ID:spokino,项目名称:OrientDB-NET.binary,代码行数:49,代码来源:SqlSelectTests.cs

示例8: ShouldDeserializeWholeStructure

        //[Fact]
        public void ShouldDeserializeWholeStructure()
        {
            /*
                The whole record is structured in three main segments
                +---------------+------------------+---------------+-------------+
                | version:byte   | className:string | header:byte[] | data:byte[]  |
                +---------------+------------------+---------------+-------------+
             */


            //byte version = 0;
            byte[] className = Encoding.UTF8.GetBytes("TestClass");
            byte[] header = new byte[0];
            byte[] data = new byte[0];

            //string serString = "ABJUZXN0Q2xhc3MpAAAAEQDI/wE=";
            string serString1 = "AAxQZXJzb24EaWQAAABEBwhuYW1lAAAAaQcOc3VybmFtZQAAAHAHEGJpcnRoZGF5AAAAdwYQY2hpbGRyZW4AAAB9AQBIZjk1M2VjNmMtNGYyMC00NDlhLWE2ODQtYjQ2ODkxNmU4NmM3DEJpbGx5MQxNYXllczGUlfWVo1IC/wE=";

            var document = new ODocument();
            document.OClassName = "TestClass";
            document.SetField<DateTime>("_date", DateTime.Now);

            var createdDocument = database
                .Create
                .Document(document)
                .Run();

            Assert.Equal(document.GetField<DateTime>("_date").Date, createdDocument.GetField<DateTime>("eeee"));
            var serBytes1 = Convert.FromBase64String(serString1);
            var doc = serializer.Deserialize(serBytes1, new ODocument());
        }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:32,代码来源:RecordBinaryDeserializationTest.cs

示例9: Serialize

        internal static string Serialize(ODocument document)
        {
            if (!document.HasField("@ClassName"))
            {
                throw new OException(OExceptionType.Serialization, "Document doesn't contain @ClassName field which is required for serialization.");
            }

            return document.GetField<string>("@ClassName") + "@" + SerializeDocument(document);
        }
开发者ID:krisnod,项目名称:OrientDB-NET.binary-old,代码行数:9,代码来源:RecordSerializer.cs

示例10: Serialize

        public byte[] Serialize(ODocument document)
        {
            if (!document.HasField("@OClassName"))
            {
                throw new OException(OExceptionType.Serialization, "Document doesn't contain @OClassName field which is required for serialization.");
            }

            return Encoding.UTF8.GetBytes(document.GetField<string>("@OClassName") + "@" + SerializeDocument(document));
        }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:9,代码来源:RecordCSVSerializer.cs

示例11: ShouldInsertValuesWithNewLines

        public void ShouldInsertValuesWithNewLines()
        {
            _database
                         .Create.Class("TestClass")
                         .Run();

            ODocument document = new ODocument();
            document.OClassName = "TestClass";
            document
                .SetField("foo", "foo string value \r\n test te5435ttrtr")
                .SetField("bar", 12345);

            ODocument insertedDocument = _database
                .Insert(document)
                .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,代码行数:21,代码来源:GitHub_issue83.cs

示例12: ShouldInsertAndReadValuesWithTrailingBackslash

        public void ShouldInsertAndReadValuesWithTrailingBackslash()
        {
            _database
                         .Create.Class("TestClass")
                         .Run();

            ODocument document = new ODocument();
            document.OClassName = "TestClass";
            document
                .SetField("foo", "foo string value \\ test \\")
                .SetField("bar", 12345);

            ODocument insertedDocument = _database
                .Insert(document)
                .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"));


            List<ODocument> documents = _database
                        .Select()
                        .From(insertedDocument)
                        .ToList();

            Assert.AreEqual(documents.Count, 1);

            for (int i = 0; i < documents.Count; i++)
            {
                Assert.AreEqual(documents[i].ORID, insertedDocument.ORID);
                Assert.AreEqual(documents[i].OClassName, insertedDocument.OClassName);
                Assert.AreEqual(documents[i].GetField<string>("foo"), insertedDocument.GetField<string>("foo"));
                Assert.AreEqual(documents[i].GetField<int>("bar"), insertedDocument.GetField<int>("bar"));
            }
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:37,代码来源:GitHub_issue84.cs

示例13: TestGermanFloatCulture

        public void TestGermanFloatCulture()
        {
            var floatValue = "108,4";

            float @float;
            float.TryParse(floatValue, NumberStyles.Any, CultureInfo.GetCultureInfo("de-DE"), out @float);

            var doc = new ODocument { OClassName = "TestVertex" }
                .SetField("floatField", @float);

            var insertedDoc = _database.Insert(doc).Run();

            Assert.NotNull(insertedDoc.ORID);
            Assert.Equal(doc.GetField<float>("@float"), insertedDoc.GetField<float>("@float"));
        }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:15,代码来源:GitHub_issue5.cs

示例14: ShouldInsertDocumentIntoCluster

        public void ShouldInsertDocumentIntoCluster()
        {
            using (TestDatabaseContext testContext = new TestDatabaseContext())
            {
                using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
                {
                    // prerequisites
                    database
                        .Create.Class("TestClass")
                        .Run();

                    database
                        .Create.Cluster("TestCluster", OClusterType.Physical)
                        .Run();

                    database.Command("alter class TestClass addcluster TestCluster");

                    ODocument document = new ODocument()
                        .SetField("foo", "foo string value")
                        .SetField("bar", 12345);

                    ODocument insertedDocument = database
                        .Insert(document)
                        .Into("TestClass")
                        .Cluster("TestCluster")
                        .Run();

                    Assert.True(insertedDocument.ORID != null);
                    Assert.Equal(insertedDocument.OClassName, "TestClass");
                    Assert.Equal(insertedDocument.GetField<string>("foo"), document.GetField<string>("foo"));
                    Assert.Equal(insertedDocument.GetField<int>("bar"), document.GetField<int>("bar"));
                }
            }
        }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:34,代码来源:SqlInsertTests.cs

示例15: InitializeServerConnection

        private void InitializeServerConnection(string userName, string userPassword)
        {
            _readBuffer = new byte[OClient.BufferLenght];

            // initiate socket connection
            try
            {
                _socket = new TcpClient(Hostname, Port);
            }
            catch (SocketException ex)
            {
                throw new OException(OExceptionType.Connection, ex.Message, ex.InnerException);
            }

            _networkStream = new BufferedStream(_socket.GetStream());
            _networkStream.Read(_readBuffer, 0, 2);

            OClient.ProtocolVersion = ProtocolVersion = BinarySerializer.ToShort(_readBuffer.Take(2).ToArray());

            // execute connect operation
            Connect operation = new Connect();
            operation.UserName = userName;
            operation.UserPassword = userPassword;

            Document = ExecuteOperation(operation);
            SessionId = Document.GetField<int>("SessionId");
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:27,代码来源:Connection.cs


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