@@ -1086,6 +1086,41 @@ void AssertPersons(List<Person> results, bool fetched)
10861086 }
10871087 }
10881088 }
1089+
1090+ [ Test ]
1091+ public async Task TestRefreshRemovesLazyLoadedPropertiesAsync ( )
1092+ {
1093+ using ( var outerSession = OpenSession ( ) )
1094+ {
1095+ const string query = "from Person fetch Image where Id = 1" ;
1096+ const string namePostFix = "_MODIFIED" ;
1097+ const int imageLength = 4711 ;
1098+
1099+ Person outerPerson = await ( outerSession . CreateQuery ( query ) . UniqueResultAsync < Person > ( ) ) ;
1100+
1101+ Assert . That ( outerPerson . Name . EndsWith ( namePostFix ) , Is . False ) ; // Normal property
1102+ Assert . That ( outerPerson . Image . Length , Is . EqualTo ( 1 ) ) ; // Lazy Property
1103+
1104+ // Changing the properties of the person in a different sessions
1105+ using ( var innerSession = OpenSession ( ) )
1106+ {
1107+ var transaction = innerSession . BeginTransaction ( ) ;
1108+
1109+ Person innerPerson = await ( innerSession . CreateQuery ( query ) . UniqueResultAsync < Person > ( ) ) ;
1110+ innerPerson . Image = new byte [ imageLength ] ;
1111+ innerPerson . Name += namePostFix ;
1112+ await ( innerSession . UpdateAsync ( innerPerson ) ) ;
1113+
1114+ await ( transaction . CommitAsync ( ) ) ;
1115+ }
1116+
1117+ // Refreshing the person in the outer session
1118+ await ( outerSession . RefreshAsync ( outerPerson ) ) ;
1119+
1120+ Assert . That ( outerPerson . Name . EndsWith ( namePostFix ) , Is . True ) ; // Value has changed
1121+ Assert . That ( outerPerson . Image . Length , Is . EqualTo ( imageLength ) ) ; // This is still the old value
1122+ }
1123+ }
10891124
10901125 private static Person GeneratePerson ( int i , Person bestFriend )
10911126 {
0 commit comments