Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

.Any() method on IEnumerable from ReadRows improperly moves the pointer to the next item in the object #84

Open
motoyugota opened this issue Mar 11, 2023 · 0 comments

Comments

@motoyugota
Copy link

ExcelSheet sheet = importer.ReadSheet();
var items = sheet.ReadRows<MyItem>();

if (!items.Any())
{
    //Handle empty set
}

var list = items.ToList(); // This is now missing the first item from the sheet.

Following the standards for IEnumerable in C#, .Any() is not supposed to modify the IEnumerable in any way, including changing the pointer location in the collection, so you should still be able to retrieve the entire list.

It looks like .ToList() also has the same problem, so if you do .ToList() followed by .Any(), it now returns false instead of true. ToList is also not supposed to modify the IEnumerable.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant