-
Notifications
You must be signed in to change notification settings - Fork 89
Feature/cancellation token 2 #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/cancellation token 2 #55
Conversation
where TDocument : IDocument<TKey> | ||
where TKey : IEquatable<TKey> | ||
{ | ||
if (!documents.Any()) | ||
var documentList = documents.ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did it have to be a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the previous code was double enumating the enumeration which could cause issues. turning it into a list means it is enumerated once preventing issues.
{ | ||
await HandlePartitioned<TDocument, TKey>(group.FirstOrDefault()).InsertManyAsync(group.ToList(), null, cancellationToken); | ||
} | ||
} | ||
else | ||
{ | ||
await GetCollection<TDocument, TKey>().InsertManyAsync(documents.ToList(), null, cancellationToken); | ||
await GetCollection<TDocument, TKey>().InsertManyAsync(documentsList.ToList(), null, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume documentsList.ToList() is redundant now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch - has been removed
} | ||
} | ||
else | ||
{ | ||
GetCollection<TDocument, TKey>().InsertMany(documents.ToList()); | ||
GetCollection<TDocument, TKey>().InsertMany(documentList.ToList(), cancellationToken: cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume documentsList.ToList() is redundant now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch - has been removed
…ngodb-generic-repository into feature/cancellation-token-2
Added cancellation tokens every where. They should be mostly non-breaking changes including for mocks in unit tests.