update DbRepository

This commit is contained in:
2025-09-11 18:35:17 +02:00
parent be96bd0c07
commit 8743325067
3 changed files with 5 additions and 33 deletions

View File

@@ -1,7 +1,6 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System.Linq.Expressions;
namespace DigitalData.Core.Infrastructure;
@@ -35,7 +34,7 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
return entities;
}
public IQueryable<TEntity> Where() => Entities.AsQueryable();
public IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> expression) => Entities.AsQueryable().Where(expression);
public IQueryable<TEntity> Get() => Entities.AsNoTracking();
@@ -86,5 +85,5 @@ public class DbRepository : IRepository
_factory = factory;
}
public IRepository<TEntity> Entity<TEntity>() => _factory.Get<TEntity>();
public IRepository<TEntity> Entity<TEntity>() where TEntity : IEntity => _factory.Get<TEntity>();
}