@@ -42,48 +42,46 @@ protected override HbmMapping GetMappings()
4242
4343 protected override void OnSetUp ( )
4444 {
45- using ( var session = OpenSession ( ) )
46- using ( var transaction = session . BeginTransaction ( ) )
47- {
48- var e1 = new Entity { Name = "Bob" } ;
49- session . Save ( e1 ) ;
45+ using var session = OpenSession ( ) ;
46+ using var transaction = session . BeginTransaction ( ) ;
47+
48+ var e1 = new Entity { Name = "Bob" } ;
49+ session . Save ( e1 ) ;
5050
51- var e2 = new Entity { Name = "Sally" } ;
52- session . Save ( e2 ) ;
51+ var e2 = new Entity { Name = "Sally" } ;
52+ session . Save ( e2 ) ;
5353
54- transaction . Commit ( ) ;
55- }
54+ transaction . Commit ( ) ;
5655 }
5756
5857 protected override void OnTearDown ( )
5958 {
60- using ( var session = OpenSession ( ) )
61- using ( var transaction = session . BeginTransaction ( ) )
62- {
63- // The HQL delete does all the job inside the database without loading the entities, but it does
64- // not handle delete order for avoiding violating constraints if any. Use
65- // session.Delete("from System.Object");
66- // instead if in need of having NHbernate ordering the deletes, but this will cause
67- // loading the entities in the session.
68- session . CreateQuery ( "delete from System.Object" ) . ExecuteUpdate ( ) ;
59+ using var session = OpenSession ( ) ;
60+ using var transaction = session . BeginTransaction ( ) ;
61+
62+ // The HQL delete does all the job inside the database without loading the entities, but it does
63+ // not handle delete order for avoiding violating constraints if any. Use
64+ // session.Delete("from System.Object");
65+ // instead if in need of having NHbernate ordering the deletes, but this will cause
66+ // loading the entities in the session.
67+ session . CreateQuery ( "delete from System.Object" ) . ExecuteUpdate ( ) ;
6968
70- transaction . Commit ( ) ;
71- }
69+ transaction . Commit ( ) ;
7270 }
7371
7472 [ Test ]
7573 public async Task YourTestNameAsync ( )
7674 {
77- using ( var session = OpenSession ( ) )
78- using ( var transaction = session . BeginTransaction ( ) )
79- {
80- var result = from e in session . Query < Entity > ( )
81- where e . Name == "Bob"
82- select e ;
75+ using var session = OpenSession ( ) ;
76+ using var transaction = session . BeginTransaction ( ) ;
77+
78+ var result = session
79+ . Query < Entity > ( )
80+ . Where ( e => e . Name == "Bob" ) ;
81+
82+ Assert . That ( await ( result . ToListAsync ( ) ) , Has . Count . EqualTo ( 1 ) ) ;
8383
84- Assert . That ( await ( result . ToListAsync ( ) ) , Has . Count . EqualTo ( 1 ) ) ;
85- await ( transaction . CommitAsync ( ) ) ;
86- }
84+ await ( transaction . CommitAsync ( ) ) ;
8785 }
8886 }
8987}
0 commit comments