默认情况下,我尝试过滤一些DbSet。
尝试覆盖DbContext.Set(TEntity实体);方法。想知道这是否是过滤DbSet的最佳方法,还是应该实现自定义DbSet以返回此类值?
public override DbSet<TEntity> Set<TEntity>()
{
if (typeof(TEntity).Equals(typeof(IBuildingEntity)))
{
return (DbSet<TEntity>)base.Set<IBuildingEntity>()
.Join(this.BuildingTypes.Join(
this.view_SecureData.Where(m => m.IdUser == this._helperCurrentContext.UserId),
bt => bt.IdSecureData,
sd => sd.Id,
(bt, bld) => bt),
bld => bld.IdType,
bt => bt.Id,
(bld, bt) => bld);
}
return base.Set<TEntity>();
}