public virtual IQueryable <TEntity> PrepareQuery <TEntity>(FilterBase filter) where TEntity : ModelBase { IQueryable <TEntity> query = ApplyAsNoTracking(db.Set <TEntity>(), filter); query = ApplyIncludes(query, filter); return(filter.FilterObjects(query).Cast <TEntity>()); }