refactor: remove IRepository and DbRepository
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
using System.Linq.Expressions;
|
||||
using DigitalData.Core.Abstractions.Interfaces;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
#endif
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
#region IRepository
|
||||
#region Read
|
||||
public static IEnumerable<TEntity> GetAll<TEntity>(this IRepository repository) where TEntity : IEntity
|
||||
=> repository.Entity<TEntity>().GetAll();
|
||||
|
||||
public static Task<IEnumerable<TEntity>> GetAllAsync<TEntity>(this IRepository repository, CancellationToken cancel = default) where TEntity : IEntity
|
||||
=> repository.Entity<TEntity>().GetAllAsync(cancel);
|
||||
|
||||
public static IQueryable<TEntity> Where<TEntity>(this IRepository repository, Expression<Func<TEntity, bool>> expression)
|
||||
where TEntity : IEntity
|
||||
=> repository.Entity<TEntity>().Where(expression);
|
||||
#endregion
|
||||
|
||||
#region Create
|
||||
public static Task<TEntity> CreateAsync<TEntity>(this IRepository repository, TEntity entity, CancellationToken cancel = default)
|
||||
where TEntity : IEntity
|
||||
=> repository.Entity<TEntity>().CreateAsync(entity, cancel);
|
||||
|
||||
public static Task<TEntity> CreateAsync<TEntity, TDto>(this IRepository repository, TDto dto, CancellationToken cancel = default)
|
||||
where TEntity : IEntity
|
||||
where TDto : IDto<TEntity>
|
||||
=> repository.Entity<TEntity>().CreateAsync(dto, cancel);
|
||||
|
||||
public static Task<IEnumerable<TEntity>> CreateAsync<TEntity>(this IRepository repository, IEnumerable<TEntity> entities, CancellationToken cancel = default)
|
||||
where TEntity : IEntity
|
||||
=> repository.Entity<TEntity>().CreateAsync(entities, cancel);
|
||||
|
||||
public static Task<IEnumerable<TEntity>> CreateAsync<TEntity, TDto>(this IRepository repository, IEnumerable<TDto> dtos, CancellationToken cancel = default)
|
||||
where TEntity : IEntity
|
||||
where TDto : IDto<TEntity>
|
||||
=> repository.Entity<TEntity>().CreateAsync(dtos, cancel);
|
||||
#endregion Create
|
||||
|
||||
#region Update
|
||||
public static Task UpdateAsync<TEntity, TDto>(this IRepository repository, TDto dto, Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default)
|
||||
where TEntity : IEntity
|
||||
where TDto : IDto<TEntity>
|
||||
=> repository.Entity<TEntity>().UpdateAsync(dto, expression, cancel);
|
||||
|
||||
public static Task UpdateAsync<TEntity, TDto>(this IRepository repository, TDto dto, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default)
|
||||
where TEntity : IEntity
|
||||
where TDto : IDto<TEntity>
|
||||
=> repository.Entity<TEntity>().UpdateAsync(dto, query, cancel);
|
||||
#endregion
|
||||
|
||||
#region Delete
|
||||
public static Task DeleteAsync<TEntity>(this IRepository repository, Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default)
|
||||
where TEntity : IEntity
|
||||
=> repository.Entity<TEntity>().DeleteAsync(expression, cancel);
|
||||
|
||||
public static Task DeleteAsync<TEntity>(this IRepository repository, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default)
|
||||
where TEntity : IEntity
|
||||
=> repository.Entity<TEntity>().DeleteAsync(query, cancel);
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
@@ -99,12 +99,6 @@ public interface IRepository<TEntity>
|
||||
IQueryable<TEntity> ReadOnly();
|
||||
#endregion
|
||||
}
|
||||
|
||||
public interface IRepository
|
||||
{
|
||||
IRepository<TEntity> Entity<TEntity>() where TEntity : IEntity;
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user