File tree Expand file tree Collapse file tree 4 files changed +18
-2
lines changed
Examples/IntegrationTestApp Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ private static async Task Main()
118118 logger . LogInformation ( $ "Name: { data . Firstname } { data . Lastname } ") ;
119119 logger . LogInformation ( $ "Year of birth: { data . YearOfBirth } ") ;
120120 logger . LogInformation ( $ "Phone number: { data . PhoneNumber } ") ;
121+ logger . LogInformation ( $ "Priority number: { data . PriorityNumber } ") ;
121122 }
122123
123124 var indexKeys = dataManager . ReadIndexKeys < TestIndexData , string > ( x => x . PhoneNumber ) ;
@@ -130,6 +131,10 @@ private static async Task Main()
130131 logger . LogInformation ( $ "Id: { id } ") ;
131132 }
132133 }
134+
135+ var nulledIndexValue = await dataManager . Read < TestIndexData > ( 2 ) ;
136+ nulledIndexValue . PriorityNumber = 2 ;
137+ await dataManager . Write ( nulledIndexValue ) ;
133138
134139 write = await dataManager . Write ( new TestUniqueIndexData
135140 {
Original file line number Diff line number Diff line change @@ -8,5 +8,6 @@ namespace IntegrationTestApp
88 public class TestIndexData : TestData
99 {
1010 [ Index ] [ Key ( 5 ) ] public string PhoneNumber { get ; set ; }
11+ [ Index ] [ Key ( 6 ) ] public int ? PriorityNumber { get ; set ; }
1112 }
1213}
Original file line number Diff line number Diff line change @@ -141,7 +141,16 @@ public async Task<bool> Index<TDataType>(TDataType data) where TDataType : DataE
141141 index = await FileStreamer . ReadDataFromStream < Index < object > > ( indexFileName ) ;
142142 _logger . LogTrace ( "Loaded index data" ) ;
143143 var otherKeys = index . Keys
144- . Where ( x => ( x . Value is null || ! x . Value . Equals ( indexKey ) ) && x . Ids . Any ( y => y == data . Id ) )
144+ . Where ( x => (
145+ ( x . Value is null && indexKey != null ) ||
146+ ( indexKey is null && x . Value != null ) ||
147+ (
148+ x . Value is null ||
149+ ! x . Value . Equals ( indexKey )
150+ )
151+ ) &&
152+ x . Ids . Any ( y => y == data . Id )
153+ )
145154 . ToArray ( ) ;
146155 if ( otherKeys . Any ( ) )
147156 {
@@ -155,7 +164,7 @@ public async Task<bool> Index<TDataType>(TDataType data) where TDataType : DataE
155164 _logger . LogTrace ( "Removed old index key" ) ;
156165 }
157166
158- var key = index . Keys . FirstOrDefault ( x => x . Value . Equals ( indexKey ) ) ;
167+ var key = index . Keys . FirstOrDefault ( x => ( x . Value is null && indexKey is null ) || ( x . Value != null && x . Value . Equals ( indexKey ) ) ) ;
159168 if ( key is null )
160169 {
161170 _logger . LogTrace ( "Index key doesn't already exist" ) ;
Original file line number Diff line number Diff line change 24240.4.0 - Handled unique indexes
25250.5.0 - Allowed keys to be read from index
26260.5.1 - Fixed issue with indexing nullable values where moving off of null would throw an exception
27+ 0.5.2 - More fixing for nullable indexed values
2728 </PackageReleaseNotes >
2829 <PackageRequireLicenseAcceptance >true</PackageRequireLicenseAcceptance >
2930 <NeutralLanguage >en-GB</NeutralLanguage >
You can’t perform that action at this time.
0 commit comments