Skip to content
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

Implementing ISoftDeleted should update properties when you call IDocumentSession.Delete<T>(T document) #2924

Open
haefele opened this issue Jan 23, 2024 · 0 comments
Milestone

Comments

@haefele
Copy link
Contributor

haefele commented Jan 23, 2024

Hey, I run into a small issue with the ISoftDeleted interface.

In the docs it says:

Implementing ISoftDeleted on your document means that:
* Those same properties will be updated when you delete a document that is in memory if you call IDocumentSession.Delete<T>(T document)

But that doesn't seem to be the case, at least I can't get it to work.

As a simple means of reproduction, I added this test to soft_deletes.cs in DocumentDbTests project:

[Fact]
public async Task delete_sets_metadata_properties()
{
    var doc1 = new SoftDeletedDocument { Id = "50" };
    theSession.Store(doc1);
    await theSession.SaveChangesAsync();

    await using var session2 = theStore.IdentitySession();
    var loadedDoc = session2.Load<SoftDeletedDocument>(doc1.Id);
    session2.Delete(loadedDoc);
    await session2.SaveChangesAsync();

    loadedDoc.DeletedAt.ShouldNotBeNull();
    loadedDoc.Deleted.ShouldBeTrue();
}

Maybe I'm misunderstanding the part ...when you delete a document that is in memory...? Or maybe it's an actual bug.

@jeremydmiller jeremydmiller added this to the 7.1.0 milestone Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants