Created
November 9, 2020 13:30
-
-
Save ennerperez/42e9d63b77943dab07eb01531844806f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.EntityFrameworkCore.Query; | |
using Abstractions.Entities; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Threading.Tasks; | |
namespace Persistence.Abstractions | |
{ | |
public interface IRepository<TEntity> : IRepository<TEntity, int> where TEntity : class, IEntity<int> | |
{ | |
} | |
public interface IRepository<TEntity, TKey> where TEntity : class, IEntity<TKey> where TKey : struct, IComparable<TKey>, IEquatable<TKey> | |
{ | |
Task<IList<TResult>> ReadAsync<TResult>( | |
Expression<Func<TEntity, TResult>> selector = null, | |
Expression<Func<TEntity, bool>> predicate = null, | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, | |
int? skip = 0, int? take = null, | |
bool disableTracking = false, | |
bool ignoreQueryFilters = false); | |
IList<TResult> Read<TResult>( | |
Expression<Func<TEntity, TResult>> selector = null, | |
Expression<Func<TEntity, bool>> predicate = null, | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, | |
int? skip = 0, int? take = null, | |
bool disableTracking = false, | |
bool ignoreQueryFilters = false); | |
Task<IList<TResult>> SearchAsync<TResult>( | |
Expression<Func<TEntity, TResult>> selector = null, | |
string criteria = "", | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, | |
int? skip = 0, int? take = null, | |
bool disableTracking = false, | |
bool ignoreQueryFilters = false); | |
IList<TResult> Search<TResult>( | |
Expression<Func<TEntity, TResult>> selector = null, | |
string criteria = "", | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, | |
int? skip = 0, int? take = null, | |
bool disableTracking = false, | |
bool ignoreQueryFilters = false); | |
Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate = null); | |
int Count(Expression<Func<TEntity, bool>> predicate = null); | |
Task<long> LongCountAsync(Expression<Func<TEntity, bool>> predicate = null); | |
long LongCount(Expression<Func<TEntity, bool>> predicate = null); | |
bool Any(Expression<Func<TEntity, bool>> predicate = null); | |
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> predicate = null); | |
Task CreateAsync(params TEntity[] entity); | |
void Create(params TEntity[] entity); | |
Task CreateOrUpdateAsync(params TEntity[] entity); | |
void CreateOrUpdate(params TEntity[] entity); | |
Task UpdateAsync(params TEntity[] entity); | |
void Update(params TEntity[] entity); | |
Task DeleteAsync(params TKey[] key); | |
void Delete(params TKey[] key); | |
// * // | |
Task<TResult> FirstOrDefaultAsync<TResult>( | |
Expression<Func<TEntity, TResult>> selector = null, | |
Expression<Func<TEntity, bool>> predicate = null, | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, | |
bool disableTracking = false, | |
bool ignoreQueryFilters = false); | |
TResult FirstOrDefault<TResult>( | |
Expression<Func<TEntity, TResult>> selector = null, | |
Expression<Func<TEntity, bool>> predicate = null, | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, | |
bool disableTracking = false, | |
bool ignoreQueryFilters = false); | |
Task<TResult> LastOrDefaultAsync<TResult>( | |
Expression<Func<TEntity, TResult>> selector = null, | |
Expression<Func<TEntity, bool>> predicate = null, | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, | |
bool disableTracking = false, | |
bool ignoreQueryFilters = false); | |
TResult LastOrDefault<TResult>( | |
Expression<Func<TEntity, TResult>> selector = null, | |
Expression<Func<TEntity, bool>> predicate = null, | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, | |
bool disableTracking = false, | |
bool ignoreQueryFilters = false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment