fixture.cs
来自「NHibernate NET开发者所需的」· CS 代码 · 共 56 行
CS
56 行
using System;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.NH467
{
[TestFixture]
public class Fixture : BugTestCase
{
public override string BugNumber
{
get { return "NH467"; }
}
[Test]
public void WhereClauseInManyToOneNavigation()
{
User inactive = new User();
inactive.Id = 10;
inactive.Name = "inactive";
inactive.IsActive = 0;
Employee employee = new Employee();
employee.Id = 20;
employee.User = inactive;
using (ISession s = OpenSession())
using (ITransaction t = s.BeginTransaction())
{
s.Save(inactive);
s.Save(employee);
t.Commit();
}
using (ISession s = OpenSession())
using (ITransaction t = s.BeginTransaction())
{
Employee loaded = (Employee) s.Get(typeof(Employee), employee.Id);
Assert.IsNotNull(loaded.User);
try
{
NHibernateUtil.Initialize(loaded.User);
Assert.Fail("Should not have initialized");
}
catch (ObjectNotFoundException)
{
// Correct
}
s.Delete("from Employee");
s.Delete("from User");
t.Commit();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?