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


C# ODatabase.LoadRecord方法代码示例

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


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

示例1: TestLoadRecord

        static void TestLoadRecord()
        {
            using (ODatabase database = new ODatabase(_hostname, _port, _databaseName, ODatabaseType.Document, _username, _password))
            {
                TestClass obj = database.LoadRecord<TestClass>(new ORID(6, 0));

                Console.WriteLine(obj);
            }
        }
开发者ID:yojimbo87,项目名称:Eastern,代码行数:9,代码来源:Program.cs

示例2: TestPocoCreateAndLoadAndDeleteRecord

        public void TestPocoCreateAndLoadAndDeleteRecord()
        {
            using (ODatabase database = new ODatabase(_hostname, _port, _databaseName, ODatabaseType.Document, _username, _password))
            {
                TestClass foo = new TestClass();
                foo.IsBool = true;

                ORecord recordCreated = database.CreateRecord("TestClass", foo);
                TestClass fooRetrieved = database.LoadRecord<TestClass>(recordCreated.ORID);

                Assert.IsTrue(fooRetrieved.IsBool == foo.IsBool);

                bool isRecordDeleted = database.DeleteRecord(recordCreated.ORID);

                Assert.IsTrue(isRecordDeleted);

                fooRetrieved = null;
                fooRetrieved = database.LoadRecord<TestClass>(recordCreated.ORID);

                Assert.IsTrue(fooRetrieved == null);
            }
        }
开发者ID:yojimbo87,项目名称:Eastern,代码行数:22,代码来源:ODatabaseCrudTests.cs

示例3: TestQuery

        static void TestQuery()
        {
            using (ODatabase database = new ODatabase(_hostname, _port, _databaseName, ODatabaseType.Document, _username, _password))
            {
                TestClass obj = database.LoadRecord<TestClass>(new ORID(6, 0));

                foreach (string s in database.Query("select from cluster:ouser"))
                {
                    Console.WriteLine(s);
                }
            }
        }
开发者ID:yojimbo87,项目名称:Eastern,代码行数:12,代码来源:Program.cs

示例4: TestPocoCreateAndLoadRecord

        public void TestPocoCreateAndLoadRecord()
        {
            using (ODatabase database = new ODatabase(_hostname, _port, _databaseName, ODatabaseType.Document, _username, _password))
            {
                TestClass foo = new TestClass();

                // basic types
                foo.IsBool = true;
                foo.ByteNumber = 22;
                foo.ShortNumber = 22222;
                foo.IntNumber = 12345678;
                foo.LongNumber = 1234567890123;
                foo.FloatNumber = 3.14f;
                foo.DoubleNumber = 12343.23442;
                foo.DecimalNumber = new Decimal(1234567.890);
                foo.DateTime = DateTime.Now;
                foo.String = "Bra\"vo \\ asdf";

                // collections
                foo.StringArray = new string[] { "str elem 1", "str elem 2", "str elem 3" };
                foo.StringList = new List<string>() { "str list elem 1", "str list elem 2", "str list elem 3" };

                // embedded document
                foo.NestedClass = new TestNestedClass();
                foo.NestedClass.NestedString = "test nested string";
                foo.NestedClass.StringArray = new string[] { "str elem 1", "str elem 2", "str elem 3" };
                foo.NestedClass.StringList = new List<string>() { "str list elem 1", "str list elem 2", "str list elem 3" };

                // collection of embedded documents
                foo.ObjectList = new List<TestNestedClass>();
                foo.ObjectList.Add(new TestNestedClass() {
                    NestedString = "test embedded doc 1 string",
                    StringArray = new string[] { "str elem 1", "str elem 2", "str elem 3" },
                    StringList = new List<string>() { "str list elem 1", "str list elem 2", "str list elem 3" }
                });
                foo.ObjectList.Add(new TestNestedClass()
                {
                    NestedString = "test embedded doc2 string",
                    StringArray = new string[] { "str elem 11", "str elem 12", "str elem 13" },
                    StringList = new List<string>() { "str list elem 11", "str list elem 12", "str list elem 13" }
                });

                // single and collection of ORIDs
                foo.SingleOrid = new ORID("#10:1334");
                foo.OridList = new List<ORID>();
                foo.OridList.Add(new ORID("#11:123"));
                foo.OridList.Add(new ORID("#22:12345"));
                foo.OridList.Add(new ORID("#33:1234567"));

                ORecord recordCreated = database.CreateRecord("TestClass", foo);

                TestClass fooRetrieved = database.LoadRecord<TestClass>(recordCreated.ORID);

                // basic types
                Assert.IsTrue(fooRetrieved.Null == null);
                Assert.IsTrue(fooRetrieved.IsBool == foo.IsBool);
                Assert.IsTrue(fooRetrieved.ByteNumber == foo.ByteNumber);
                Assert.IsTrue(fooRetrieved.ByteNumber == foo.ByteNumber);
                Assert.IsTrue(fooRetrieved.IntNumber == foo.IntNumber);
                Assert.IsTrue(fooRetrieved.LongNumber == foo.LongNumber);
                Assert.IsTrue(fooRetrieved.FloatNumber == foo.FloatNumber);
                Assert.IsTrue(fooRetrieved.DoubleNumber == foo.DoubleNumber);
                Assert.IsTrue(fooRetrieved.DecimalNumber == foo.DecimalNumber);
                Assert.IsTrue(fooRetrieved.DateTime.ToString() == foo.DateTime.ToString());
                Assert.IsTrue(fooRetrieved.String == foo.String);

                // collections
                Assert.IsTrue(fooRetrieved.StringArray.Length == foo.StringArray.Length);
                Assert.IsTrue(fooRetrieved.StringArray[0] == foo.StringArray[0]);
                Assert.IsTrue(fooRetrieved.StringArray[1] == foo.StringArray[1]);
                Assert.IsTrue(fooRetrieved.StringArray[2] == foo.StringArray[2]);
                Assert.IsTrue(fooRetrieved.StringList.Count == foo.StringList.Count);
                Assert.IsTrue(fooRetrieved.StringList[0] == foo.StringList[0]);
                Assert.IsTrue(fooRetrieved.StringList[1] == foo.StringList[1]);
                Assert.IsTrue(fooRetrieved.StringList[2] == foo.StringList[2]);

                // embedded document
                Assert.IsTrue(fooRetrieved.NestedClass.NestedString == foo.NestedClass.NestedString);
                Assert.IsTrue(fooRetrieved.NestedClass.StringArray.Length == foo.NestedClass.StringArray.Length);
                Assert.IsTrue(fooRetrieved.NestedClass.StringArray[0] == foo.NestedClass.StringArray[0]);
                Assert.IsTrue(fooRetrieved.NestedClass.StringArray[1] == foo.NestedClass.StringArray[1]);
                Assert.IsTrue(fooRetrieved.NestedClass.StringArray[2] == foo.NestedClass.StringArray[2]);
                Assert.IsTrue(fooRetrieved.NestedClass.StringList.Count == foo.NestedClass.StringList.Count);
                Assert.IsTrue(fooRetrieved.NestedClass.StringList[0] == foo.NestedClass.StringList[0]);
                Assert.IsTrue(fooRetrieved.NestedClass.StringList[1] == foo.NestedClass.StringList[1]);
                Assert.IsTrue(fooRetrieved.NestedClass.StringList[2] == foo.NestedClass.StringList[2]);

                // collection of embedded documents
                Assert.IsTrue(fooRetrieved.ObjectList.Count == foo.ObjectList.Count);
                Assert.IsTrue(fooRetrieved.ObjectList[0].NestedString == foo.ObjectList[0].NestedString);
                Assert.IsTrue(fooRetrieved.ObjectList[0].StringArray.Length == foo.ObjectList[0].StringArray.Length);
                Assert.IsTrue(fooRetrieved.ObjectList[0].StringArray[0] == foo.ObjectList[0].StringArray[0]);
                Assert.IsTrue(fooRetrieved.ObjectList[0].StringArray[1] == foo.ObjectList[0].StringArray[1]);
                Assert.IsTrue(fooRetrieved.ObjectList[0].StringArray[2] == foo.ObjectList[0].StringArray[2]);
                Assert.IsTrue(fooRetrieved.ObjectList[0].StringList.Count == foo.ObjectList[0].StringList.Count);
                Assert.IsTrue(fooRetrieved.ObjectList[0].StringList[0] == foo.ObjectList[0].StringList[0]);
                Assert.IsTrue(fooRetrieved.ObjectList[0].StringList[1] == foo.ObjectList[0].StringList[1]);
                Assert.IsTrue(fooRetrieved.ObjectList[0].StringList[2] == foo.ObjectList[0].StringList[2]);
                Assert.IsTrue(fooRetrieved.ObjectList[1].NestedString == foo.ObjectList[1].NestedString);
                Assert.IsTrue(fooRetrieved.ObjectList[1].StringArray.Length == foo.ObjectList[1].StringArray.Length);
//.........这里部分代码省略.........
开发者ID:yojimbo87,项目名称:Eastern,代码行数:101,代码来源:ODatabaseCrudTests.cs


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