Skip to content

Commit a94b29f

Browse files
committed
Fix incorrect EntitySetState.TotalItemCount calculation
1 parent 6e4aa4d commit a94b29f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Orm/Xtensive.Orm/Orm/Internals/EntitySetState.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2008-2020 Xtensive LLC.
1+
// Copyright (C) 2008-2021 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov
@@ -375,12 +375,11 @@ private void UpdateSyncedState(IEnumerable<Key> keys, long? count)
375375
Rebind();
376376
}
377377

378-
public void UpdateCachedState(IEnumerable<Key> keys, long? count)
378+
public void UpdateCachedState(IEnumerable<Key> syncronizedKeys, long? count)
379379
{
380380
FetchedKeys.Clear();
381381
var becameRemovedOnSever = new HashSet<Key>(removedKeys.Keys);
382-
TotalItemCount = count;
383-
foreach (var key in keys) {
382+
foreach (var key in syncronizedKeys) {
384383
if (addedKeys.ContainsKey(key)) {
385384
_ = addedKeys.Remove(key);
386385
}
@@ -392,6 +391,10 @@ public void UpdateCachedState(IEnumerable<Key> keys, long? count)
392391
foreach (var removedOnServer in becameRemovedOnSever) {
393392
_ = removedKeys.Remove(removedOnServer);
394393
}
394+
395+
TotalItemCount = count.HasValue
396+
? FetchedKeys.Count - removedKeys.Count + AddedItemsCount
397+
: count;
395398
}
396399

397400
private void EnsureFetchedKeysIsNotNull()

0 commit comments

Comments
 (0)