本文整理汇总了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);
}
示例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();
}
}