Skip to content

Commit

Permalink
add bulk delete method in repository
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmoudalaskalany committed Nov 3, 2024
1 parent 39f3b5e commit b635e3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Template.Common/Infrastructure/Repository/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,11 @@ IList<TReturn> FindGrouped<TResult, TKey, TGroup, TReturn>(
/// </summary>
/// <param name="entities"></param>
void RemoveRange(IEnumerable<T> entities);

/// <summary>
/// Remove Bulk With Predicate
/// </summary>
/// <param name="predicate"></param>
Task<int> RemoveBulk(Expression<Func<T, bool>> predicate);
}
}
5 changes: 5 additions & 0 deletions Template.Infrastructure/Repository/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,10 @@ public void RemoveRange(IEnumerable<T> entities)
DbSet.RemoveRange(entities);
}

public async Task<int> RemoveBulk(Expression<Func<T, bool>> predicate)
{
return await DbSet.Where(predicate).ExecuteDeleteAsync();
}

}
}

0 comments on commit b635e3f

Please sign in to comment.