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


C# Country.AddCity方法代码示例

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


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

示例1: AssignCountry

        public virtual void AssignCountry(Country country)
        {
            Validate.ThatArgumentNotNull(() => country);

            if (Country == country)
                return;

            Country = country;
            Country.AddCity(this);
        }
开发者ID:matanzg,项目名称:codecovered,代码行数:10,代码来源:City.cs

示例2: InsertSomeData

        public static void InsertSomeData(ISessionFactory sessionFactory)
        {
            using (var session = sessionFactory.OpenSession())
            using (var tx = session.BeginTransaction())
            {
                var israel = new Country { Name = "Israel" };
                var telaviv = new City { Name = "TelAviv" };
                israel.AddCity(telaviv);

                session.Save(israel);

                var address = new Address { City = telaviv, Number = 100, PostalCode = 101, Street = "200" };
                var matan = new Person
                {
                    Gender = Gender.Male,
                    Name = "Matan",
                    HomeAddress = address
                };

                session.Save(matan);

                var store = new Store { Contact = matan, Name = "Main Office" };
                var branch1 = new Branch
                {
                    Address = address,
                    Manager = matan,
                    Name = "branch1",
                    Location = (Point)Default.GeometryFactory.CreatePoint(new Coordinate(32, 34))
                };

                var branch2 = new Branch
                {
                    Address = address,
                    Manager = matan,
                    Name = "branch2",
                    Location = (Point)Default.GeometryFactory.CreatePoint(new Coordinate(32.5, 34.5))
                };

                store.AddBranch(branch1);
                store.AddBranch(branch2);

                var milk = new Product { Name = "milk", UnitPrice = 10, Description = "moo" };
                var bread = new Product { Name = "bread", UnitPrice = 8, Description = "poof" };

                session.Save(milk);
                session.Save(bread);

                branch1.AddProductToInventory(milk, 10);
                branch1.AddProductToInventory(bread, 15);
                branch2.AddProductToInventory(milk, 20);

                session.Save(store);
                tx.Commit();
            }
        }
开发者ID:matanzg,项目名称:codecovered,代码行数:55,代码来源:Stubs.cs


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