本文整理汇总了C#中DAO.GetById方法的典型用法代码示例。如果您正苦于以下问题:C# DAO.GetById方法的具体用法?C# DAO.GetById怎么用?C# DAO.GetById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAO
的用法示例。
在下文中一共展示了DAO.GetById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_Save_Load_Customer
public void Can_Save_Load_Customer()
{
Customer customer = new Customer();
customer.CustomerLocation = new CustomerLocation();
customer.CustomerLocation.One = "United Kingdom";
customer.CustomerLocation.Two = "North America";
DAO<Customer> customerDAO = new DAO<Customer>();
NHibernateHelper.Session.Save(customer.CustomerLocation); // Note: Can't cascade
customerDAO.MakePersistent(customer);
NHibernateHelper.Session.Clear();
Customer reloaded = customerDAO.GetById(customer.Id);
Assert.AreEqual(customer.Id, reloaded.Id);
//TODO: Uncomment this assertion once Equals on customer is done
//Assert.AreEqual(customer, reloaded);
Assert.IsNotNull(reloaded.CustomerLocation);
Assert.AreEqual("United Kingdom", reloaded.CustomerLocation.One);
}