Skip to content

Expressions not working with global query filters #33

@Seramis

Description

@Seramis

I'm trying to use Expressionify together with global query filters and it seems it is not working.

To reproduce:

  1. Create entity Tenant
  2. Create entity User, which has Tenant and TenantId property
  3. Create entity Product, which has User and UserId property
  4. Create Expressionify method public static int GetTenantId(Product p) => p.User.TenantId; into Product entity
  5. In DbContext.OnModelCreating(), add filter: modelBuilder.Entity<Product>().HasQueryFilter(x => x.GetTenantId() == 3);

Exception:

Message: 
System.TypeLoadException : Method 'PrecompileQuery' in type 'Clave.Expressionify.ExpressionableQueryCompiler' from assembly 'Clave.Expressionify, Version=6.6.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

Stack Trace: 
ExpressionifyDbContextOptionsExtension.ApplyServices(IServiceCollection services)
ServiceProviderCache.ApplyServices(IDbContextOptions options, ServiceCollection services)
ServiceProviderCache.<GetOrAdd>g__BuildServiceProvider|4_1(IDbContextOptions _, ValueTuple`2 arguments)
<>c.<GetOrAdd>b__4_0(IDbContextOptions contextOptions, ValueTuple`2 tuples)
ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired)
DbContext.get_ContextServices()
DbContext.get_InternalServiceProvider()
IServiceProvider>.get_Instance()
InfrastructureExtensions.GetService(IInfrastructure`1 accessor, Type serviceType)
InfrastructureExtensions.GetService[TService](IInfrastructure`1 accessor)
AccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
DatabaseFacade.get_Dependencies()
IDatabaseFacadeDependenciesAccessor.get_Dependencies()
RelationalDatabaseFacadeExtensions.OpenConnection(DatabaseFacade databaseFacade)
AppDbContext.ctor() line 271
EntityFilterEfTests.CreateContext() line 226
EntityFilterEfTests.Products_TenantNotSet_Returns_AllProducts() line 155
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions