refactor(Repository): add Query getter metod to Repository calss and interface to be able to create read-only query without expression

This commit is contained in:
tekh 2025-10-13 11:55:49 +02:00
parent 1e35692a02
commit 00e5f6c0e9
2 changed files with 7 additions and 0 deletions

View File

@ -40,6 +40,11 @@ public interface IRepository<TEntity>
#endregion Create #endregion Create
#region Read #region Read
#if NET
public
#endif
IQueryable<TEntity> Query { get; }
#if NET #if NET
public public
#endif #endif

View File

@ -73,6 +73,8 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
#endregion Create #endregion Create
#region Read #region Read
public virtual IQueryable<TEntity> Query => Entities.AsNoTracking();
public virtual IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> expression) => Entities.AsNoTracking().Where(expression); public virtual IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> expression) => Entities.AsNoTracking().Where(expression);
public virtual IEnumerable<TEntity> GetAll() => Entities.AsNoTracking().ToList(); public virtual IEnumerable<TEntity> GetAll() => Entities.AsNoTracking().ToList();