DD.WellWorkover.Cloud/AsbCloudInfrastructure/Repository/QueryContainer.cs

30 lines
877 B
C#
Raw Normal View History

using AsbCloudDb.Model;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
namespace AsbCloudInfrastructure.Repository
{
2023-04-13 11:15:45 +05:00
#nullable enable
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-13 11:15:45 +05:00
#nullable disable
}