forked from ddrilling/AsbCloudServer
30 lines
844 B
C#
30 lines
844 B
C#
using AsbCloudDb.Model;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace AsbCloudInfrastructure.Repository
|
|
{
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
} |