2024-07-04 11:02:45 +05:00
|
|
|
using AsbCloudDb.Model;
|
2022-12-01 15:56:11 +05:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure.Repository
|
|
|
|
{
|
2023-04-18 16:22:53 +05:00
|
|
|
|
2022-12-01 15:56:11 +05:00
|
|
|
public class QueryContainer<TEntity> where TEntity : class, IId
|
|
|
|
{
|
|
|
|
protected readonly IAsbCloudDbContext dbContext;
|
|
|
|
protected readonly DbSet<TEntity> dbSet;
|
|
|
|
protected readonly Func<IQueryable<TEntity>> GetQuery;
|
|
|
|
|
|
|
|
public QueryContainer(IAsbCloudDbContext context)
|
|
|
|
{
|
|
|
|
dbContext = context;
|
|
|
|
dbSet = context.Set<TEntity>();
|
|
|
|
GetQuery = () => dbSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
public QueryContainer(IAsbCloudDbContext context, Func<DbSet<TEntity>, IQueryable<TEntity>> makeQuery)
|
|
|
|
{
|
|
|
|
dbContext = context;
|
|
|
|
dbSet = context.Set<TEntity>();
|
|
|
|
GetQuery = () => makeQuery(dbSet);
|
|
|
|
}
|
|
|
|
}
|
2023-04-18 16:22:53 +05:00
|
|
|
|
2022-12-01 15:56:11 +05:00
|
|
|
}
|