aspnetboilerplate: Custom Filter not working in EF 6
I try to implement a custom filter in my multi dbcontext and not work correctly, I try to implement in a fresh solution but I have the same error (ABP version 4.2 / MVC / AngularJs) Here is my code
public interface IMustHaveCompany
{
long CompanyId { get; set; }
}
public class Person : FullAuditedEntity, IMustHaveCompany
{
public long CompanyId { get; set; }
public string Name { get; set; }
}
// On coreModule -> PreInitialize()
...
Configuration.UnitOfWork.RegisterFilter("CompanyFilter", true);
// On DbContext Class
public override void Initialize()
{
base.Initialize();
// If I uncomment this the stack say me
// System.ApplicationException: Filter name CompanyFilter not found
//this.SetFilterScopedParameterValue(
// "CompanyFilter",
// "companyId",
// 2);
}
protected void OnodelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Filter("CompanyFilter",
(IMustHaveCompany entity, int companyId) => entity.CompanyId == companyId, () =>
{
return 19;
});
}
// I try to call on TenantDashboardAppService
CurrentUnitOfWork.SetFilterParameter("CompanyFilter", "CompanyId", 19);
var q = _personManager.Persons.ToArray();
public interface IPersonManager : IDomainService
{
IQueryable<Person> Persons { get; }
}
public class PersonManager : demoServiceBase, IPersonManager
{
private readonly IRepository<Person> _repository;
public PersonManager(IRepository<Person> repository)
{
_repository = repository;
}
public virtual IQueryable<Person> Persons
{
get { return _repository.GetAll(); }
}
}
What is wrong??? When I look on Configuration.UnitOfWork the filter is regitered on PreInit with 0 parameter, but it’s the same for tenant May/Must
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 26 (10 by maintainers)
No problem, I will try to reproduce it. It should be easy.