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


C# ODatabase.Update方法代码示例

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


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

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

示例2: ShouldUpdateRecord

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

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

                var cd = database.Create.Document(document).Run();
                cd.SetField("bar", 54321);

                var ud = database.Update(cd).Run();
                cd.SetField("bar", 9876);
                var ud1 = database.Update(cd).Run();
            }
        }
开发者ID:mdekrey,项目名称:OrientDB-NET.binary,代码行数:22,代码来源:UpdateRecordTest.cs

示例3: ShouldUpdateClassFromObject

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

                    database
                        .Insert(profile)
                        .Run();

                    database
                        .Insert(profile)
                        .Run();

                    profile.Name = "Julia";
                    profile.Surname = "Bravo";

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

                    Assert.AreEqual(documentsUpdated, 2);

                    List<TestProfileClass> documents = database
                        .Select()
                        .From<TestProfileClass>()
                        .ToList<TestProfileClass>();

                    Assert.AreEqual(documents.Count, 2);

                    for (int i = 0; i < documents.Count; i++)
                    {
                        Assert.IsTrue(documents[i].ORID != null);
                        Assert.AreEqual(documents[i].OClassName, typeof(TestProfileClass).Name);
                        Assert.AreEqual(documents[i].Name, profile.Name);
                        Assert.AreEqual(documents[i].Surname, profile.Surname);
                    }
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:48,代码来源:SqlUpdateTests.cs

示例4: ShouldUpdateRemoveFieldQuery

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

                    ODocument document1 = database
                        .Insert()
                        .Into("TestClass")
                        .Set("foo", "foo string value1")
                        .Set("bar", 11111)
                        .Run();

                    ODocument document2 = database
                        .Insert()
                        .Into("TestClass")
                        .Set("foo", "foo string value2")
                        .Set("bar", 12345)
                        .Run();

                    int documentsUpdated = database
                        .Update(document2)
                        .Remove("bar")
                        .Run();

                    Assert.AreEqual(documentsUpdated, 1);

                    List<ODocument> documents = database
                        .Select()
                        .From("TestClass")
                        .Where("foo").Equals("foo string value2")
                        .ToList();

                    Assert.AreEqual(documents.Count, 1);

                    Assert.AreEqual(documents[0].ORID, document2.ORID);
                    Assert.AreEqual(documents[0].OClassName, document2.OClassName);
                    Assert.AreEqual(documents[0].GetField<string>("foo"), document2.GetField<string>("foo"));
                    Assert.IsFalse(documents[0].HasField("bar"));
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:47,代码来源:SqlUpdateTests.cs

示例5: ShouldUpdateRemoveCollectionItem

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

                    ODocument document1 = database
                        .Insert()
                        .Into("TestClass")
                        .Set("foo", new List<string>() { "foo1", "foo2" })
                        .Set("bar", 11111)
                        .Run();

                    ODocument document2 = database
                        .Insert()
                        .Into("TestClass")
                        .Set("foo", new List<string>() { "foo1", "foo2" })
                        .Set("bar", 12345)
                        .Run();

                    int documentsUpdated = database
                        .Update(document2)
                        .Remove("foo", "foo2")
                        .Run();

                    Assert.AreEqual(documentsUpdated, 1);

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

                    Assert.AreEqual(documents.Count, 1);

                    Assert.AreEqual(documents[0].ORID, document2.ORID);
                    Assert.AreEqual(documents[0].OClassName, document2.OClassName);

                    List<string> foos = new List<string>() { "foo1" };

                    Assert.AreEqual(documents[0].GetField<List<string>>("foo").Count, foos.Count);
                    Assert.AreEqual(documents[0].GetField<List<string>>("foo")[0], foos[0]);

                    Assert.AreEqual(documents[0].GetField<int>("bar"), document2.GetField<int>("bar"));
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:52,代码来源:SqlUpdateTests.cs

示例6: ShouldUpdateRecordSet

        public void ShouldUpdateRecordSet()
        {
            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 document1 = database
                        .Insert(document)
                        .Run();

                    ODocument document2 = database
                        .Insert(document)
                        .Run();

                    int documentsUpdated = database
                        .Update(document2.ORID)
                        .Set("bar", 54321)
                        .Set("baz", "new baz value")
                        .Run();

                    Assert.AreEqual(documentsUpdated, 1);

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

                    Assert.AreEqual(documents.Count, 1);

                    Assert.AreEqual(documents[0].ORID, document2.ORID);
                    Assert.AreEqual(documents[0].OClassName, document2.OClassName);
                    Assert.AreEqual(documents[0].GetField<string>("foo"), document2.GetField<string>("foo"));
                    Assert.AreEqual(documents[0].GetField<int>("bar"), 54321);
                    Assert.AreEqual(documents[0].GetField<string>("baz"), "new baz value");
                }
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:49,代码来源:SqlUpdateTests.cs


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