@@ -42,48 +42,46 @@ protected override HbmMapping GetMappings()
42
42
43
43
protected override void OnSetUp ( )
44
44
{
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 ) ;
50
50
51
- var e2 = new Entity { Name = "Sally" } ;
52
- session . Save ( e2 ) ;
51
+ var e2 = new Entity { Name = "Sally" } ;
52
+ session . Save ( e2 ) ;
53
53
54
- transaction . Commit ( ) ;
55
- }
54
+ transaction . Commit ( ) ;
56
55
}
57
56
58
57
protected override void OnTearDown ( )
59
58
{
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 ( ) ;
69
68
70
- transaction . Commit ( ) ;
71
- }
69
+ transaction . Commit ( ) ;
72
70
}
73
71
74
72
[ Test ]
75
73
public async Task YourTestNameAsync ( )
76
74
{
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 ) ) ;
83
83
84
- Assert . That ( await ( result . ToListAsync ( ) ) , Has . Count . EqualTo ( 1 ) ) ;
85
- await ( transaction . CommitAsync ( ) ) ;
86
- }
84
+ await ( transaction . CommitAsync ( ) ) ;
87
85
}
88
86
}
89
87
}
0 commit comments