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


C# Session.OpenTransaction方法代码示例

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


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

示例1: CreateNodesAndSubnodes

        public void CreateNodesAndSubnodes()
        {
            Store store = new Store("xmlfs5");
            Workspace workspace = new Workspace(store, "ws");
            Session session = new Session(workspace);

            INode root = session.Workspace.RootNode;

            using (var tr = session.OpenTransaction())
            {
                for (int k = 1; k <= 10; k++)
                {
                    INode node = session.CreateNode(root, "node" + k, new Property[] {
                        new Property("Value", k)
                    });

                    for (int j = 1; j <= 10; j++)
                        session.CreateNode(node, "subnode" + j, new Property[] {
                            new Property("ParentValue", k),
                            new Property("Value", j)
                        });
                }

                tr.Complete();
            }

            for (int k = 1; k <= 10; k++)
            {
                Assert.IsTrue(File.Exists("xmlfs5/node" + k + ".xml"));
                Assert.AreEqual(k, store.LoadProperties("/node" + k)["Value"].Value);

                for (int j = 1; j <= 10; j++)
                {
                    Assert.IsTrue(File.Exists("xmlfs5/node" + k + "/subnode" + j + ".xml"));
                    var properties = store.LoadProperties("/node" + k + "/subnode" + j);

                    Assert.AreEqual(k, properties["ParentValue"].Value);
                    Assert.AreEqual(j, properties["Value"].Value);
                }
            }
        }
开发者ID:ajlopez,项目名称:AjCoRe,代码行数:41,代码来源:SessionStoreTests.cs

示例2: CreateNodes

        public void CreateNodes()
        {
            Store store = new Store("xmlfs4");
            Workspace workspace = new Workspace(store, "ws");
            Session session = new Session(workspace);

            INode root = session.Workspace.RootNode;

            using (var tr = session.OpenTransaction())
            {
                for (int k = 1; k <= 10; k++)
                    session.CreateNode(root, "node" + k, new Property[] {
                        new Property("Value", k)
                    });

                tr.Complete();
            }

            for (int k = 1; k <= 10; k++)
            {
                Assert.IsTrue(File.Exists("xmlfs4/node" + k + ".xml"));
                Assert.AreEqual(k, store.LoadProperties("/node" + k)["Value"].Value);
            }
        }
开发者ID:ajlopez,项目名称:AjCoRe,代码行数:24,代码来源:SessionStoreTests.cs

示例3: NorthwindContext

 public NorthwindContext(Domain domain)
 {
   session = domain.OpenSession();
   transactionScope = session.OpenTransaction();
 }
开发者ID:jogibear9988,项目名称:ormbattle,代码行数:5,代码来源:NorthwindContext.cs

示例4: CreateNodesAndSubnodesRemoveNodes

        public void CreateNodesAndSubnodesRemoveNodes()
        {
            Store store = new Store("xmlfs6");
            Workspace workspace = new Workspace(store, "ws");
            Session session = new Session(workspace);

            INode root = session.Workspace.RootNode;

            using (var tr = session.OpenTransaction())
            {
                for (int k = 1; k <= 10; k++)
                {
                    INode node = session.CreateNode(root, "node" + k, new Property[] {
                        new Property("Value", k)
                    });

                    for (int j = 1; j <= 10; j++)
                        session.CreateNode(node, "subnode" + j, new Property[] {
                            new Property("ParentValue", k),
                            new Property("Value", j)
                        });
                }

                tr.Complete();
            }

            using (var tr = session.OpenTransaction())
            {
                for (int k = 1; k <= 10; k++)
                    session.RemoveNode(root.ChildNodes["node" + k]);

                tr.Complete();
            }

            for (int k = 1; k <= 10; k++)
                Assert.IsFalse(File.Exists("xmlfs6/node" + k + ".xml"));
        }
开发者ID:ajlopez,项目名称:AjCoRe,代码行数:37,代码来源:SessionStoreTests.cs

示例5: SetPropertyValueAndRollback

        public void SetPropertyValueAndRollback()
        {
            Store store = new Store("xmlfs2");
            Workspace workspace = new Workspace(store, "ws");
            Session session = new Session(workspace);

            INode node = session.Workspace.RootNode;

            using (var tr = session.OpenTransaction())
            {
                node["Name"] = "Adam";

                Assert.AreEqual("Adam", node["Name"]);
            }

            PropertyList properties = store.LoadProperties("/");
            Assert.AreEqual("Root", properties["Name"].Value);
        }
开发者ID:ajlopez,项目名称:AjCoRe,代码行数:18,代码来源:SessionStoreTests.cs

示例6: RemoveExistingNode

        public void RemoveExistingNode()
        {
            Store store = new Store("xmlfs3");
            Workspace workspace = new Workspace(store, "ws");
            Session session = new Session(workspace);

            INode node = session.Workspace.RootNode;

            Assert.IsTrue(Directory.Exists("xmlfs3/father"));
            Assert.IsTrue(File.Exists("xmlfs3/father.xml"));

            using (var tr = session.OpenTransaction())
            {
                session.RemoveNode(node.ChildNodes["father"]);

                tr.Complete();
            }

            Assert.IsFalse(Directory.Exists("xmlfs3/father"));
            Assert.IsFalse(File.Exists("xmlfs3/father.xml"));
        }
开发者ID:ajlopez,项目名称:AjCoRe,代码行数:21,代码来源:SessionStoreTests.cs


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