question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetAllIncluding contains deleted contents

See original GitHub issue

For example, there are entities,

public class User : Entity
{
    public string Name { get; set; }
    public List<UserPermission> Permissions { get; set; }
}

public class UserPermission : Entity. ISoftDelete
{
    public int UserId { get; set; }
    public string Permission { get; set; }
    public bool IsDeleted { get; set; }
}

Remove a permission from a user like this,

var perm = _permissionRepo.GetAll().First(p => p.UserId == 2 && p.Permission == "admin");
_permissionRepo.Delete(perm);  // let's say perm.Id == 3
CurrentUnitOfWork.SaveChanges();

Now,I get the user and his permissions,but the permissions contains deleted contents

var userAfter = _userRepo.GetAllIncluding(u => u.Permissions).First(u => u.Id == 2);  
//permission(3) appears  in userAfter.Permissions 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
hikalkancommented, Jun 1, 2018

Thank you @acjh for the repro.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Activate SoftDelete data filter when including collections
GetAllIncluding already filters deleted rows and only gets non-deleted entities (github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/…).
Read more >
Repositories | Documentation Center | ABP.IO
Provides DeleteAsync method to delete multiple entities by a filter. Querying / LINQ over the Repositories. Repositories provide the GetQueryableAsync() method ...
Read more >
Loading Related Entities - EF6
Eager loading is achieved by use of the Include method. For example, the queries below will load blogs and all the posts related...
Read more >
Determining If Entity Is Unique In Repository Pattern
Hello, Using c# and ASP .Net Core 6 I have an N-Tier web application that has implemented a Repository Pattern and Unit of...
Read more >
Generic Repository Pattern In ASP.NET Core
This article demonstrates a sample Application, which has one too many relationships in ASP.NET Core with Entity Framework Core.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found