@@ -30,48 +30,46 @@ protected override HbmMapping GetMappings()
30
30
31
31
protected override void OnSetUp ( )
32
32
{
33
- using ( var session = OpenSession ( ) )
34
- using ( var transaction = session . BeginTransaction ( ) )
35
- {
36
- var e1 = new Entity { Name = "Bob" } ;
37
- session . Save ( e1 ) ;
33
+ using var session = OpenSession ( ) ;
34
+ using var transaction = session . BeginTransaction ( ) ;
35
+
36
+ var e1 = new Entity { Name = "Bob" } ;
37
+ session . Save ( e1 ) ;
38
38
39
- var e2 = new Entity { Name = "Sally" } ;
40
- session . Save ( e2 ) ;
39
+ var e2 = new Entity { Name = "Sally" } ;
40
+ session . Save ( e2 ) ;
41
41
42
- transaction . Commit ( ) ;
43
- }
42
+ transaction . Commit ( ) ;
44
43
}
45
44
46
45
protected override void OnTearDown ( )
47
46
{
48
- using ( var session = OpenSession ( ) )
49
- using ( var transaction = session . BeginTransaction ( ) )
50
- {
51
- // The HQL delete does all the job inside the database without loading the entities, but it does
52
- // not handle delete order for avoiding violating constraints if any. Use
53
- // session.Delete("from System.Object");
54
- // instead if in need of having NHbernate ordering the deletes, but this will cause
55
- // loading the entities in the session.
56
- session . CreateQuery ( "delete from System.Object" ) . ExecuteUpdate ( ) ;
47
+ using var session = OpenSession ( ) ;
48
+ using var transaction = session . BeginTransaction ( ) ;
49
+
50
+ // The HQL delete does all the job inside the database without loading the entities, but it does
51
+ // not handle delete order for avoiding violating constraints if any. Use
52
+ // session.Delete("from System.Object");
53
+ // instead if in need of having NHbernate ordering the deletes, but this will cause
54
+ // loading the entities in the session.
55
+ session . CreateQuery ( "delete from System.Object" ) . ExecuteUpdate ( ) ;
57
56
58
- transaction . Commit ( ) ;
59
- }
57
+ transaction . Commit ( ) ;
60
58
}
61
59
62
60
[ Test ]
63
61
public void YourTestName ( )
64
62
{
65
- using ( var session = OpenSession ( ) )
66
- using ( var transaction = session . BeginTransaction ( ) )
67
- {
68
- var result = from e in session . Query < Entity > ( )
69
- where e . Name == "Bob"
70
- select e ;
63
+ using var session = OpenSession ( ) ;
64
+ using var transaction = session . BeginTransaction ( ) ;
65
+
66
+ var result = session
67
+ . Query < Entity > ( )
68
+ . Where ( e => e . Name == "Bob" ) ;
69
+
70
+ Assert . That ( result . ToList ( ) , Has . Count . EqualTo ( 1 ) ) ;
71
71
72
- Assert . That ( result . ToList ( ) , Has . Count . EqualTo ( 1 ) ) ;
73
- transaction . Commit ( ) ;
74
- }
72
+ transaction . Commit ( ) ;
75
73
}
76
74
}
77
75
}
0 commit comments