8000 Enumerable Gotchas: Modifying Query Property · Issue #48 · colin-higgins/colin-higgins.github.io · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Enumerable Gotchas: Modifying Query Property #48
Open
@colin-higgins

Description

@colin-higgins

If you modify the property which you queried on, the enumerable re-evaluates and it's empty.

var oldResults = test.ExecuteStageImportRecords();

var oldThings = test.DatabaseMock.Things.Where(i => i.SummaryId == test.SummaryId);

foreach (var record in oldThings)
{
    record.SummaryId--;
    record.UniqueId = Guid.NewGuid();
}

var oldGuids = oldThings.Select(i => i.UniqueId);

var actualThings = test.ExecuteStageImportRecords();

var containsOldRecords = actualResults.Any(r => oldGuids.Contains(r.Id));

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0