I'm trying to filter some of my DbSet by default.
tried overriding the DbContext.Set(TEntity entity); method. wondering if this is the best way to filter a DbSet or should I implement a custom DbSet to return such value?
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>();
}