• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ODocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ODocument的典型用法代码示例。如果您正苦于以下问题:C# ODocument类的具体用法?C# ODocument怎么用?C# ODocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: Response

        public ODocument Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            // operation specific fields
            byte existByte = BinarySerializer.ToByte(response.Data.Skip(offset).Take(1).ToArray());
            offset += 1;

            if (existByte == 0)
            {
                document.SetField("Exists", false);
            }
            else
            {
                document.SetField("Exists", true);
            }

            return document;
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:26,代码来源:DbExist.cs


示例2: Response

        public override ODocument Response(Response response)
        {
            Dictionary<ORID, int> entries = new Dictionary<ORID, int>();

            ODocument document = new ODocument();
            if (response == null)
            {
                return document;
            }

            var reader = response.Reader;
            if (response.Connection.ProtocolVersion > 26 && response.Connection.UseTokenBasedSession)
                ReadToken(reader);

            // (count:int)[(key:binary)(value:binary)]
            var bytesLength = reader.ReadInt32EndianAware();
            var count = reader.ReadInt32EndianAware();
            for (int i = 0; i < count; i++)
            {
                // key
                short clusterId = reader.ReadInt16EndianAware();
                long clusterPosition = reader.ReadInt64EndianAware();
                var rid = new ORID(clusterId, clusterPosition);

                // value
                var value = reader.ReadInt32EndianAware();

                entries.Add(rid, value);
            }
            document.SetField<Dictionary<ORID, int>>("entries", entries);
            return document;
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:32,代码来源:SBTreeBonsaiGetEntriesMajor.cs


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


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


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


示例6: Response

        public override ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            var reader = response.Reader;
            if (response.Connection.ProtocolVersion > 26 && response.Connection.UseTokenBasedSession)
                ReadToken(reader);

            // operation specific fields
            byte existByte = reader.ReadByte();

            if (existByte == 0)
            {
                document.SetField("Exists", false);
            }
            else
            {
                document.SetField("Exists", true);
            }

            return document;
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:27,代码来源:DbExist.cs


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


示例8: ShouldSerializeNumbers

        public void ShouldSerializeNumbers()
        {
            string recordString = "[email protected]:123b,ShortNumber:1234s,IntNumber:123456,LongNumber:12345678901l,FloatNumber:3.14f,DoubleNumber:3.14d,DecimalNumber:1234567.8901c,embedded:(ByteNumber:123b,ShortNumber:1234s,IntNumber:123456,LongNumber:12345678901l,FloatNumber:3.14f,DoubleNumber:3.14d,DecimalNumber:1234567.8901c)";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField("ByteNumber", byte.Parse("123"))
                .SetField("ShortNumber", short.Parse("1234"))
                .SetField("IntNumber", 123456)
                .SetField("LongNumber", 12345678901)
                .SetField("FloatNumber", 3.14f)
                .SetField("DoubleNumber", 3.14)
                .SetField("DecimalNumber", new Decimal(1234567.8901))
                .SetField("embedded.ByteNumber", byte.Parse("123"))
                .SetField("embedded.ShortNumber", short.Parse("1234"))
                .SetField("embedded.IntNumber", 123456)
                .SetField("embedded.LongNumber", 12345678901)
                .SetField("embedded.FloatNumber", 3.14f)
                .SetField("embedded.DoubleNumber", 3.14)
                .SetField("embedded.DecimalNumber", new Decimal(1234567.8901));

            string serializedRecord = document.Serialize();

            Assert.AreEqual(serializedRecord, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:25,代码来源:RecordSerializationTests.cs


示例9: ShouldDeleteDocumentFromDocumentOClassName

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

                    database
                        .Create.Document("TestClass")
                        .Set("foo", "foo string value1")
                        .Set("bar", 12345)
                        .Run();

                    database
                        .Create.Document("TestClass")
                        .Set("foo", "foo string value2")
                        .Set("bar", 54321)
                        .Run();

                    ODocument document = new ODocument();
                    document.OClassName = "TestClass";

                    int documentsDeleted = database
                        .Delete.Document(document)
                        .Run();

                    Assert.AreEqual(documentsDeleted, 2);
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:34,代码来源:SqlDeleteDocumentTests.cs


示例10: ShouldGenerateCreateEdgeObjectFromDocumentToDocumentQuery

        public void ShouldGenerateCreateEdgeObjectFromDocumentToDocumentQuery()
        {
            TestProfileClass profile = new TestProfileClass();
            profile.Name = "Johny";
            profile.Surname = "Bravo";

            ODocument vertexFrom = new ODocument();
            vertexFrom.ORID = new ORID(8, 0);

            ODocument vertexTo = new ODocument();
            vertexTo.ORID = new ORID(8, 1);

            string generatedQuery = new OSqlCreateEdge()
                .Edge(profile)
                .From(vertexFrom)
                .To(vertexTo)
                .ToString();

            string query =
                "CREATE EDGE TestProfileClass " +
                "FROM #8:0 TO #8:1 " +
                "SET Name = 'Johny', " +
                "Surname = 'Bravo'";

            Assert.AreEqual(generatedQuery, query);
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:26,代码来源:SqlGenerateCreateEdgeQueryTests.cs


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


示例12: Deserialize

        internal static ODocument Deserialize(ORID orid, int version, ORecordType type, short classId, byte[] rawRecord)
        {
            ODocument document = new ODocument();
            document.ORID = orid;
            document.OVersion = version;
            document.OType = type;
            document.OClassId = classId;

            string recordString = BinarySerializer.ToString(rawRecord).Trim();

            int atIndex = recordString.IndexOf('@');
            int colonIndex = recordString.IndexOf(':');
            int index = 0;

            // parse class name
            if ((atIndex != -1) && (atIndex < colonIndex))
            {
                document.OClassName = recordString.Substring(0, atIndex);
                index = atIndex + 1;
            }

            // start document parsing with first field name
            do
            {
                index = ParseFieldName(index, recordString, document);
            }
            while (index < recordString.Length);

            return document;
        }
开发者ID:krisnod,项目名称:OrientDB-NET.binary-old,代码行数:30,代码来源:RecordSerializer.cs


示例13: SerializeDocument

        private static string SerializeDocument(ODocument document)
        {
            string serializedString = "";

            if (document.Keys.Count > 0)
            {
                int iteration = 0;

                foreach (KeyValuePair<string, object> field in document)
                {
                    // serialize only fields which doesn't start with @ character
                    if ((field.Key.Length > 0) && (field.Key[0] != '@'))
                    {
                        serializedString += field.Key + ":";
                        serializedString += SerializeValue(field.Value);
                    }

                    iteration++;

                    if (iteration < document.Keys.Count)
                    {
                        if ((field.Key.Length > 0) && (field.Key[0] != '@'))
                        {
                            serializedString += ",";
                        }
                    }
                }
            }

            return serializedString;
        }
开发者ID:krisnod,项目名称:OrientDB-NET.binary-old,代码行数:31,代码来源:RecordSerializer.cs


示例14: Response

        public ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            var reader = response.Reader;

            // operation specific fields
            byte existByte = reader.ReadByte();

            if (existByte == 0)
            {
                document.SetField("Exists", false);
            }
            else
            {
                document.SetField("Exists", true);
            }

            return document;
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:25,代码来源:DbExist.cs


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


示例16: Response

        public override ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            var reader = response.Reader;

            if (response.Connection.ProtocolVersion > 26 && response.Connection.UseTokenBasedSession)
                ReadToken(reader);

            short len = reader.ReadInt16EndianAware();
            Dictionary<string, string> configList = new Dictionary<string, string>();
            for (int i = 0; i < len; i++)
            {
                string key = reader.ReadInt32PrefixedString();
                string value = reader.ReadInt32PrefixedString();
                configList.Add(key, value);
            }
            document.SetField<Dictionary<string, string>>("config", configList);
            return document;
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:25,代码来源:ConfigList.cs


示例17: RunInternal

        private OCommandResult RunInternal()
        {
            try
            {
                if (_parameters == null)
                    throw new ArgumentNullException("_parameters");

                var paramsDocument = new ODocument();
                paramsDocument.OClassName = "";
                paramsDocument.SetField(OClient.ProtocolVersion < 22 ? "params" : "parameters", _parameters);

                var serializer = RecordSerializerFactory.GetSerializer(_connection.Database);


                CommandPayloadCommand payload = new CommandPayloadCommand();
                payload.Text = ToString();
                payload.SimpleParams = serializer.Serialize(paramsDocument);

                Command operation = new Command(_connection.Database);
                operation.OperationMode = OperationMode.Synchronous;
                operation.CommandPayload = payload;

                ODocument document = _connection.ExecuteOperation(operation);

                return new OCommandResult(document);
            }
            finally
            {
                _parameters = null;
            }
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:31,代码来源:PreparedCommand.cs


示例18: ShouldRetrieveRecordMetadata

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

                    var document = new ODocument();
                    document.OClassName = "TestClass";
                    document.SetField("bar", 12345);
                    document.SetField("foo", "foo value 345");

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

                    var metadata = database
                        .Metadata
                        .ORID(createdDocument.ORID)
                        .Run();
                    Assert.IsNotNull(metadata);
                    Assert.AreEqual(createdDocument.ORID, metadata.ORID);
                    Assert.AreEqual(createdDocument.OVersion, metadata.OVersion);

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


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


示例20: Response

        public ODocument Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            // operation specific fields
            document.SetField("SessionId", BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray()));
            offset += 4;
            short clusterCount = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());
            document.SetField("ClusterCount", clusterCount);
            offset += 2;

            if (clusterCount > 0)
            {
                List<OCluster> clusters = new List<OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    cluster.Name = BinarySerializer.ToString(response.Data.Skip(offset).Take(clusterNameLength).ToArray());
                    offset += clusterNameLength;

                    cluster.Id = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    int clusterTypeLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    string clusterName = BinarySerializer.ToString(response.Data.Skip(offset).Take(clusterTypeLength).ToArray());
                    cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterName, true);
                    offset += clusterTypeLength;

                    cluster.DataSegmentID = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            int clusterConfigLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;

            document.SetField("ClusterConfig", response.Data.Skip(offset).Take(clusterConfigLength).ToArray());
            offset += clusterConfigLength;

            return document;
        }
开发者ID:simonproctor,项目名称:OrientDB-NET.binary,代码行数:59,代码来源:DbOpen.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# OEC类代码示例发布时间:2022-05-24
下一篇:
C# ODatabase类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap