Skip to content

Commit

Permalink
Remove redundant Count/Any
Browse files Browse the repository at this point in the history
  • Loading branch information
Desz01ate committed Mar 9, 2023
1 parent c370ede commit ad3fc93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,6 @@ public virtual void UpdateRange(IEnumerable<T> entities)
this.Set.UpdateRange(entities);
}

/// <inheritdoc />
public virtual bool Any(Expression<Func<T, bool>> predicate)
{
return this.Set.Any(predicate);
}

/// <inheritdoc />
public virtual int Count()
{
return this.Set.Count();
}

/// <inheritdoc />
public virtual int Count(Expression<Func<T, bool>> predicate)
{
return this.Set.Count(predicate);
}

/// <inheritdoc />
public virtual int SaveChanges()
{
Expand Down Expand Up @@ -151,28 +133,6 @@ public virtual Task UpdateRangeAsync(IEnumerable<T> entities, CancellationToken
return Task.CompletedTask;
}

/// <inheritdoc />
public virtual Task<bool> AnyAsync(
Expression<Func<T, bool>> predicate,
CancellationToken cancellationToken = default)
{
return this.Set.AnyAsync(predicate, cancellationToken);
}

/// <inheritdoc />
public virtual Task<int> CountAsync(CancellationToken cancellationToken = default)
{
return this.Set.CountAsync(cancellationToken);
}

/// <inheritdoc />
public virtual Task<int> CountAsync(
Expression<Func<T, bool>> predicate,
CancellationToken cancellationToken = default)
{
return this.Set.CountAsync(predicate, cancellationToken);
}

/// <inheritdoc />
public virtual Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Codehard.Infrastructure.EntityFramework.Interfaces;

/// <summary>
/// Defines a generic repository interface for entities of type T.
/// </summary>
/// <typeparam name="T">The type of entity to be stored in the repository.</typeparam>
public interface IRepository<T> : IQueryable<T>
where T : class
{
Expand Down Expand Up @@ -58,26 +62,6 @@ public interface IRepository<T> : IQueryable<T>
/// <param name="entities"></param>
void UpdateRange(IEnumerable<T> entities);

/// <summary>
/// Determines whether any entity satisfies a condition.
/// </summary>
/// <param name="predicate"></param>
/// <returns></returns>
bool Any(Expression<Func<T, bool>> predicate);

/// <summary>
/// Returns the number of entities in a repository.
/// </summary>
/// <returns></returns>
int Count();

/// <summary>
/// Returns the number of entities in a repository that satisfies a condition.
/// </summary>
/// <param name="predicate"></param>
/// <returns></returns>
int Count(Expression<Func<T, bool>> predicate);

/// <summary>
/// Saves all changes made in this repository context to the database.
/// </summary>
Expand Down Expand Up @@ -127,28 +111,6 @@ public interface IRepository<T> : IQueryable<T>
/// <param name="cancellationToken"></param>
Task UpdateRangeAsync(IEnumerable<T> entities, CancellationToken cancellationToken = default);

/// <summary>
/// Determines whether any entity satisfies a condition in an asynchronous manner.
/// </summary>
/// <param name="predicate"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<bool> AnyAsync(Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default);

/// <summary>
/// Returns the number of entities in a repository in an asynchronous manner.
/// </summary>
/// <returns></returns>
Task<int> CountAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Returns the number of entities in a repository that satisfies a condition in an asynchronous manner.
/// </summary>
/// <param name="predicate"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<int> CountAsync(Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default);

/// <summary>
/// Saves all changes made in this repository context to the database in an asynchronous manner.
/// </summary>
Expand Down

0 comments on commit ad3fc93

Please sign in to comment.